We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object
class ExtendObject extends Object{}
Object 函数的 length 属性值为 1。
length
MDN —— Object 构造函数的方法
有 [[Prototype]] 内置插槽,其值为 %Function.prototype%
[[Prototype]]
有 length 属性
有以下额外的属性:
const obj1 = { a: 1 } const obj2 = Object.assign({}, obj1) obj2 === obj1 // false const obj3 = { a: { b : 'b'} } const obj4 = Object.assign({}, obj3) obj4 === obj3 // false obj3.a.b = 'bb' obj4.a.b // 'bb'
一个对象,其所有键值都是基本数据类型的话,Object.assign 可以当做深拷贝来用;但是如果某个键值是对象的话,那么 Object.assign 只能作为浅拷贝。
Object.assign
该函数 length 属性值为2
// 注意第二个参数 Properties, // 不熟悉的人会误以为和 Object.assign 一样, // 其实不同,第二个参数是大对象,键值为属性描述符 Object.create (null, { a: { value: 'a' } })
Null
Object.defineProperties({}, { 'property1': { value: true, writable: true }, 'property2': { value: 'Hello', writable: false } // etc. etc. });
注意和 Object.defineProperties 区别
Object.defineProperties
Object.defineProperty({}, 'property1', { value: 42, writable: false });
注意:为 adder 创建的函数不能被ECMAScript代码直接访问
来自高级前端面试小程序第19题
var a = {}, b = '123', c = 123; a[b] = 'b'; a[c] = 'c'; console.log(a[b]) // 'c' // ------------------ var a = {}, b = Symbol('123'), c= Symbol('123'); a[b] = 'b'; a[c] = 'c'; console.log(a[b]) // 'b' // ------------------ var a = {}; b = {key: '123'}, c = {key: '456'}; a[b] = 'b'; a[c] = 'c'; console.log(a[b]) // 'c'
我错在第三个,对象键名都能错!!!对象键名除了 String 就是 Symbol,其它都会默认转成 String !!!详见 ToPropertyKey
String
Symbol
这个问题说明我虽然写了《重学js》,但是不认真!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
基本对象:普通对象(Object构造器上的属性一)
对象构造器
Object
属性的初始值class ExtendObject extends Object{}
Object( [ value ] )
Object 函数的
length
属性值为 1。Object 构造器属性
MDN —— Object 构造函数的方法
有
[[Prototype]]
内置插槽,其值为 %Function.prototype%有
length
属性有以下额外的属性:
Object.assign ( target, ...sources )
Object.create ( O, Properties )
Object
又不是Null
,抛 TypeError 异常Object.defineProperties ( O, Properties )
ObjectDefineProperties( O, Properties )
Object
,抛 TypeError 异常Object.defineProperty ( O, P, Attributes )
Object
,抛 TypeError 异常Object.entries ( O )
Object.freeze ( O )
Object
,返回 OObject.fromEntries ( iterable )
CreateDataPropertyOnObject Functions
篇幅过长,见下一篇
2020-07-29 补充
来自高级前端面试小程序第19题
我错在第三个,对象键名都能错!!!对象键名除了
String
就是Symbol
,其它都会默认转成String
!!!详见 ToPropertyKey这个问题说明我虽然写了《重学js》,但是不认真!
The text was updated successfully, but these errors were encountered: