What does the sign +
means?
Example of it's use:
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
What does the sign +
means?
Example of it's use:
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
Pragmatically, it's JavaScript shorthand for converting a value to a Number
. Technically, it's the unary plus operator, complementary to the unary negation operator.
let number = "1"
console.log(typeof number)
console.log(typeof +number)
console.log(+number)
console.log(typeof -number)
console.log(-number)
console.log(typeof +true)
console.log(+true)