xxxxxxxxxx
let x = "Java";
let y = "Script";
let z = x + y;//"Java" + "Script"
console.log(z);
xxxxxxxxxx
var str = 'Hello' + ' ' + 'world!'; // str = 'Hello world!'
// a comma ',' is the default delimiter for array.join
var str = ['Hello',' ','world!'].join(); // str = 'Hello, ,world!'
var str = ['Hello',' ','world!'].join(''); // str = 'Hello world!'
var str1 = 'Hello';
var str2 = str1.concat(' ','world!'); // str1 = 'Hello', str2 = 'Hello world!"
var str1 = 'Hello';
var str2 = `${str1} world!`; // str1 = 'Hello', str2 = 'Hello world!"
// note backticks `
xxxxxxxxxx
// the fastest way to string concat in cycle when number of string is less than 1e6
// see https://medium.com/@devchache/the-performance-of-javascript-string-concat-e52466ca2b3a
// see https://www.javaer101.com/en/article/2631962.html
function concat(arr) {
let str = '';
for (let i = 0; i < arr.length; i++) {
str += arr[i];
}
return str;
}
xxxxxxxxxx
var dest = new String("");
var src = new String("aze");
var ar = new Array();
ar.push(src);
ar.push(src);
dest = ar.join("");
xxxxxxxxxx
-------------------------------------------------------------------------------------------------------------
Autoscaling - Generating Load
-------------------------------------------------------------------------------------------------------------
sudo amazon-linux-extras install epel
sudo yum -y install stress
uptime
sudo stress --cpu 8 -v --timeout 10000s
xxxxxxxxxx
var dest = new String("");
var src = new String("aze");
dest += src + src + src + src + src;
xxxxxxxxxx
/*
Note:
Concatenation in javascript
Concat() The concat() method is used to merge two or more arrays.
This method does not change the existing arrays but instead returns a new array.
Concatenation is when you add string to an integer then the integer becomes a string.
*/
//CODE//
var myAge = 100;
console.log("My age is" + myAge);
myAge = 29;
console.log("My age next year will be" + myAge);