Javascript - typeof etc
Posted Mon 21 Dec 2015 12:41:33 PM CET
Florian Lohoff
Whats so complicated in providing methods to find a type of a variable? Reading on Stackoverflow makes you wish javascript dies sooner than later:
if (value instanceof Array) {
alert('value is Array!');
} else {
alert('Not an array');
}
Why on earth does typeof arrayvariable
return object ?!?
Okay - lets use JQuerys $.isArray(variable)
.
While at it - array.truncate(index)
would also be nice. Yes
i know you can do it with splice
or slice
but both return a new
object. I simply want to truncate the array without caring about
the additional indexes.