The Weird Thing about Javascript – Part I


This article is a recap from the youtube Talk “JS WAT Talk Reup”, which shows that Javascript has some weird things and also its powerful strengths (syntax flexibility).

Array Plus Array

[] + [] evaluates to empty string

Array Plus Object

[] + {} evaluates to [object Object]

Object Plus Array

{} + [] evaluates to 0

Object Plus Object

{} + {} evaluates to NaN

NaN join

Array(5).join(“a” – 1) + ” man” evaluates to NaNNaNNaNNaN man

javascript-trim The Weird Thing about Javascript - Part I javascript

javascript-trim

Also: typeof this (inside String.prototype function) equals to “object” instead of “string”.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
196 words
Last Post: Disable Spam Comments in WordPress by Checking Referer
Next Post: Shell Coding Exercise - Word Frequency

The Permanent URL is: The Weird Thing about Javascript – Part I

Leave a Reply