Skip to content

Instantly share code, notes, and snippets.

View AliN11's full-sized avatar
😉
Focusing

Ali Nazari AliN11

😉
Focusing
View GitHub Profile
@AliN11
AliN11 / code-quiz.txt
Last active February 17, 2019 11:40
Code Quiz outputs. Page: instagram.com/code.quiz
#1: object
#2: 57
#3: 10.5
#4: undefined
#5: John
#6: 542
#7: 113
#8: 3
#9: 64
#10: 2
@AliN11
AliN11 / javascript-exception-handler.js
Created June 23, 2019 12:17
Javascript Exception Handler
try {
var x = y / 10;
} catch(error) {
console.log(error);
}
// Console: ReferenceError: y is not defined
<?php
class Room
{
private $color = 'white';
private $size = 'xl';
public function setColor(string $color): void
{
$this->color = $color;
<?php
class Sun
{
// ...
private function __sleep() {}
private function __wakeup() {}
};
window.name = 'شایان شایان پرور';
function greeting() {
console.log('سلام آقای ' + window.name);
}
greeting(); // سلام آقای شایان شایان پرور
// ...
let name1 = "John";
let name2 = name1;
console.log(name1); // John
console.log(name2); // John
name1 = "Paolo";
console.log(name1); // Paolo
console.log(name2); // John
let house1 = {
color: 'green'
}
let house2 = house1;
console.log(house1.color); // green
console.log(house2.color); // green
house1.color = "yellow"
enum Colors {Red, Green, Blue};
console.log(typeof Colors); // object
console.log(Colors);
/*
{
'0': 'Red',
'1': 'Green',
'2': 'Blue',
// These two lines:
console.log(y); // undefined
y = "Street";
// are interpreted as:
var y;
console.log(y); // undefined
y = "Street";
let person = {
name: 'Bastian',
lastname: 'Schweinsteiger'
};
person = JSON.stringify(person);
localStorage.setItem('user', person);