Javascript: New Syntax
String Concatenation
Typically when concatenating a string you would chain items together with “” and + like so
var dog = "German Shepard";
var cat = "Himalayan Tabby";
console.log("I love my new " + dog + " but your " + cat + " is also beautiful");
however you can now insert variables dynamically into strings to make concatenation easier. Wrap variables in $. This is called “template literal”.
var dog = "German Shepard";
var cat = "Himalayan Tabby";
console.log(`I love my new ${dog} but your ${cat} is also beautiful`);
const & let
Intended to replace var.
const and let are both variables but with one key difference. let can have it’s value changed by a function, while const is truly constant and cannot be changed by anything.
Objects
When digging into objects there are two ways to identify your target. The result is identical
bracket notation
var parsedBody = JSON.parse(body);
console.log(parsedBody["results"][0]["title"]);
dot notation
var parsedBody = JSON.parse(body);
console.log(parsedBody.results.0.title);
Arrow Function
There is a new syntax for functions. The standard syntax is:
function(argument){
//code to execute
}
Arrow notation would be
(argument) => {
//code to execute
}
Comments
Recent Work
Basalt
basalt.softwareFree desktop AI Chat client, designed for developers and businesses. Unlocks advanced model settings only available in the API. Includes quality of life features like custom syntax highlighting.
BidBear
bidbear.ioBidbear is a report automation tool. It downloads Amazon Seller and Advertising reports, daily, to a private database. It then merges and formats the data into beautiful, on demand, exportable performance reports.