Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xyzdata/77f802a3a7744c85cf117d3666c85e9d to your computer and use it in GitHub Desktop.
Save xyzdata/77f802a3a7744c85cf117d3666c85e9d to your computer and use it in GitHub Desktop.
xgqfrms , react & e.preventDefault(); & e.stopPropagation();

react & e.preventDefault(); & e.stopPropagation();

xgqfrms react

    


e.preventDefault();
e.stopPropagation();
e.nativeEvent.stopImmediatePropagation();

ant-design/ant-design#6576

@xyzdata
Copy link
Author

xyzdata commented Aug 2, 2017

/* Array 对象 */ 
let arr = ["a", "b", "c"];

console.log(Object.keys(arr)); 
// "0,1,2"

/* 类数组 对象 */ 
let obj = { 0 : "a", 1 : "b", 2 : "c"};

console.log(Object.keys(obj)); 
// "0,1,2"

// 类数组 对象, 随机 key 排序 
let anObj = { 100: 'a', 2: 'b', 7: 'c' }; 

console.log(Object.keys(anObj)); 
// ['2', '7', '100']


/* Object 对象 */ 

let abc = {a: "a", b: "b", c: "c"}; 

console.log(Object.keys(abc)); 
// (3) ["a", "b", "c"] 

let xyz = {x: "xxx", y: "yyy", z: "zzz"}; 

console.log(Object.keys(xyz)); 
// (3) ["x", "y", "z"]


image

@xyzdata
Copy link
Author

xyzdata commented Aug 2, 2017

Object.keys()

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

Object.keys(obj) / Object.keys(arr)

let abc = {a: "a", b: "b", c: "c"};
console.log(Object.keys(abc));
// (3) ["a", "b", "c"]

let xyz = {x: "xxx", y: "yyy", z: "zzz"};
console.log(Object.keys(xyz));
// (3) ["x", "y", "z"]


// array like object with random key ordering
let anObj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(anObj)); 
// ['2', '7', '100']


// 类数组 对象, 随机 key 排序 
let anObj = { 100: 'a', 2: 'b', 7: 'c' }; 

console.log(Object.keys(anObj)); 
// ['2', '7', '100']


/* getFoo 是个不可枚举的属性 */ 

let my_obj = Object.create(
    {}, 
    {
        getFoo: {
            value: function() {return this.foo;}
        }
    }
);

my_obj.foo = 1;

console.log(Object.keys(my_obj)); 
// ["foo"]

console.log(my_obj);
// {foo: 1, getFoo: ƒ}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment