Skip to content

Instantly share code, notes, and snippets.

View jonaskahn's full-sized avatar
🇩🇪
I'm on it

Jonas jonaskahn

🇩🇪
I'm on it
View GitHub Profile
#!/bin/bash
# Reset
NC='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
@jonaskahn
jonaskahn / nodejs.download.js
Created June 8, 2023 15:38 — forked from ialpert/nodejs.download.js
Download file using GET and nodejs
function download(url, cb) {
var data = "";
var request = require("http").get(url, function(res) {
res.on('data', function(chunk) {
data += chunk;
});
res.on('end', function() {
cb(data);

SETUP

  1. Clone 3 sources in the sample folder. Ex:
-- SOURCE/
		--	minoda.simulation.ecsite/
		--	minoda.simulation.libs/
		--	minoda.simulation.stafftool/
function showMe(){
alert("You called from other side")
}
<html>
<body>
<script>
function hello(name) {
let phrase = `Hello, ${name}!`;
say(phrase);
}
function say(phrase) {
  • Ex 1:
function sayHi() {
  alert( "Hello" );
}

let sayHi = function() {
  alert( "Hello" );
};

Function declare

function showMessage(from, text) { // parameters: from, text
  alert(from + ': ' + text);
}

showMessage('Ann', 'Hello!'); // Ann: Hello! (*)
showMessage('Ann', "What's up?"); // Ann: What's up? (**)

Parameters

Style

  • Normal style:
result = (a !== null && a !== undefined) ? a : b;
  • Compact style:
result = a ?? b

The result of a ?? b is:

The “if” statement

  • Ex 1:
let year = prompt('In which year was the ECMAScript-2015 specification published?', '');

if (year == 2015) {
  alert( 'You guessed it right!' );
} else {
 alert( 'How can you be so wrong?' ); // any value except 2015

Let & const

let and const are the block scoped

A block is a chunk of code bounded by {}. A block lives in curly braces. Anything within curly braces is a block.

  • Ex1:
let greeter = "hey hi";

if (1) {