Due to a bug in the original C code for the implementation of Javascript, this awesome thing happens:
console.log(typeof a); // prints "object"
Due to a bug in the original C code for the implementation of Javascript, this awesome thing happens:
Here's yet another one of Javascript's endless oddities: the switch
statement uses strict comparison (think ===
instead of ==
).
There's a bunch of Web APIs that are pretty usable today:
...and more! clipboard, ambient light detection, battery status, etc.
You can run timers on the console
object, like this:
There's a nice utility that you can use to kill a process based on the port it's listening to, so for example if you have a server listening on port 80, you can run $ fkill :80
and it will murder it.
Only problem, it's made using Javascript, but if you're OK with having Node and plain-text JS files in your bin folder, you can install it with $ npm install --global fkill-cli
.
Javascript's Date object has a bunch of methods to format dates as strings, including toLocaleDateString(). This method has options for controlling the format, which include language but also more granular options such as "use 2-digit years" or "show long weekday names".
Here are some examples (tests were done in Chrome 64):
In order to use a variable as an object's key, ES6 introduced something called "computed property names", where you add brackets to your variable and it gets replaced with its value.
JSON.parse()
has an optional second parameter meant for a "reviver" function. This function will receive all keys and values from the parsed string, so you can do modifications to the result. This is useful, for example, to convert date strings to objects automatically.
Copyright 2022 · All rights reserved