Message from JavaScript discussions

September 2020

— Except, i would not use in neither for array nor object

— 

Because, 1 in a means that array is sparse - you failed to make data structure solid, probably created it with something like:

a = []
a[0] = 0
a[2] = 2
real thugs check index in array with index < a.length

— <empty> is a useful thing

— Wat empty🤨 html something or

— Language:

js


Source:
let arr = [];

arr[0] = '0';
arr[2] = '2';

console.log(arr);
// → ['0', <empty>, '2']


Result:
[ '0', <1 empty item>, '2' ]

Message permanent page

— Any React Native developer here?

— Language:

js


Source:
let a = [];

a[0] = '0';
a[2] = '2';

console.log(`
a[1]: ${a[1]}
a[1] == undefined: ${a[1] == undefined}
a[1] === undefined: ${a[1] === undefined}
1 in a: ${1 in a}
hasOwnProperty: ${Object.hasOwnProperty(a, 1)}
`)


Result:

a[1]: undefined
a[1] == undefined: true
a[1] === undefined: true
1 in a: false
hasOwnProperty: false

Message permanent page

— Its undefined but in/hOP return false

— Anyone with React Native?

— Undefined is undefined man, it doesn't even tell if the array is (was) sparse, means that data structure was screwed even more🤧 i'm sure there is some use-case for non-solid-smartass arrays but that don't deserve enough memory to remember..

Message permanent page

— Nope!

— I see you use that awful php syntax🤔