Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ExtendedArray extends Array
- {
- constructor(separator = ':', tag = 'li',...args)
- {
- super(...args);
- this._separator = separator;
- this._tag = tag;
- }
- toString(separator = this._separator)
- {
- this._separator = separator;
- return this.join(this._separator);
- }
- toHtml(tag = this._tag)
- {
- this._tag = tag;
- let base = '';
- base = this.reduce((prev,it)=>{ return `${prev}<${this._tag}>${it}</${this._tag}>`;},base)
- base = this._tag = 'li' ? `<ul>${base}</ul>` : base;
- return base;
- }
- render()
- {
- document.write(this.toHtml());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement