This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let obj = { | |
| a: 1, | |
| b: 2 | |
| } | |
| Object.defineProperty(obj, 'a', { | |
| enumerable: false | |
| }) | |
| for (let key in obj){ | |
| console.log(key) // b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var a = [1, 2, 3] | |
| for(let key in a){ | |
| console.log(key) | |
| } | |
| console.log(Object.getOwnPropertyDescriptor(a, 'length')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let obj = { | |
| a: 1 | |
| } | |
| Object.defineProperty(obj, 'a', { | |
| configurable: false | |
| }) | |
| // will throw an error | |
| Object.defineProperty(obj, 'a', { | |
| enumerable: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let obj = { | |
| a: 1 | |
| } | |
| Object.defineProperty(obj, 'a', { | |
| configurable: false | |
| }) | |
| obj.a = 3 | |
| console.log(obj.a) // 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var p1 = { | |
| get age(){ | |
| console.log('triggle get method') | |
| console.log('you can do anything as you want') | |
| return 18 | |
| }, | |
| set age(age){ | |
| console.log('triggle get method') | |
| console.log('you can do anything as you want') | |
| console.log(`you are trying to assign ${age} to this.age`) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <style> | |
| input{ | |
| font-size: 233px | |
| } | |
| </style> | |
| </head> | |
| <body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function newOperator(constructor, args) { | |
| var new_created_obj = Object.create(constructor.prototype) | |
| constructor.apply(new_created_obj, args) | |
| return new_created_obj | |
| } | |
| function Person(name, age) { | |
| this.name = name | |
| } | |
| Person.prototype.getName = function (){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PersonClass{ | |
| constructor(name, age){ | |
| this.name = name | |
| this.age = age | |
| } | |
| getName(){ | |
| return this.name | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PersonClass{ | |
| constructor(name, age){ | |
| this.name = name | |
| this.age = age | |
| } | |
| getName(){ | |
| return this.name | |
| } | |
| } | |
| class AdultClass extends PersonClass{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function.prototype.myCall = function(thisArgs) { | |
| thisArgs.$fn = this // | |
| let args = [] | |
| for(let i = 1; i<arguments.length; i++){ | |
| args.push(arguments[i]) | |
| } | |
| var result = thisArgs.$fn(...args) | |
| delete thisArgs.$fn | |
| return result | |
| } |
OlderNewer