DEV Community

Discussion on: 5 useful javascript tricks for begginers.

Collapse
 
devendra0110 profile image
Devendra Gaud

I'm still wondering how the logic works in Trick-2.

Collapse
 
developeratul profile image
Minhazur Rahman Ratul

Small trick ;)

Collapse
 
devendra0110 profile image
Devendra Gaud

Ok, I just discovered two other ways similar to that trick.

console.log(~~5.95) 
console.log(5.95 >> 0)
Enter fullscreen mode Exit fullscreen mode

And I'm more confused now.

Thread Thread
 
developeratul profile image
Minhazur Rahman Ratul

you can use what ever you want. Both of the tricks does the same thing. Or you can also use Math.floor() or Math.round()

Some comments have been hidden by the post's author - find out more