Javascript, The weird parts— Part 1

Define constructors with an arrow function

let f = function() {
this.number = 10;
};
new f(); // -> { 'number': 10 }
let f = () => {
this.number = 10;
};
new f(); // -> TypeError: f is not a constructor
1 < 2 < 3; // -> true
3 > 2 > 1; // -> false
1 < 2 < 3; // 1 < 2 -> true
true < 3; // true -> 1
1 < 3; // -> true
3 > 2 > 1; // 3 > 2 -> true
true > 1; // true -> 1
1 > 1; // -> false

Number.MIN_VALUE is the smallest number, which is greater than zero:

Number.MIN_VALUE > 0; // -> true

Strings aren’t instances of String

"abc"; // 'str'
typeof "abc"; // 'string'
"abc" instanceof String; // false

Object as a key of an object’s property

{ [{}]: {} } // -> { '[object Object]': {} }

Array.prototype.sort()

[ 10, 1, 5].sort() // -> [ 1, 10, 5]
[10, 1, 5].sort((a,b)=> a-b)

Javascript Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How To Restrict WordPress Search to Titles Only

How Writing Pure Functions Can Change Your JavaScript Bundle for the Good

javascript

Callbacks, Promises and Async/Await

PART 5: Configure Email Notification for getting build status in Jenkins.

The craziness that is JavaScript

How to use the Global Giving API

Chingu FCC Speedrun Challenge: Local Weather

Rotate Matrix in JavaScript

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yash Sharma

Yash Sharma

Javascript Developer

More from Medium

JavaScript:- Arrays

Angular vs React vs Vue : Which to choose for your career as a UI developer

JavaScript Proxy

Javascript Array Method .find()