Skip to content

Instantly share code, notes, and snippets.

View moiz-frost's full-sized avatar
🧠

Abdul Moiz Sheikh moiz-frost

🧠
View GitHub Profile
alert(1);
@moiz-frost
moiz-frost / call.js
Created September 7, 2019 19:53
call()
function printHP() {
console.log(this);
}
var car = {
year: '2010',
make: 'Honda',
color: 'White',
transmission: 'Manual',
horsePower: 140,
@moiz-frost
moiz-frost / arrow_this.js
Created September 3, 2019 20:32
Printing this with arrow functions
printThis = () => {
console.log(this);
}
var car = {
year: 2015,
printThis: printThis
}
printThis(); // will print the global/window object
@moiz-frost
moiz-frost / car_binding.js
Created September 3, 2019 19:08
Binding this context
function printCar() {
console.log(this)
}
var car = {
speed: 240
}
printCar = printCar.bind(car)
@moiz-frost
moiz-frost / car.js
Created September 3, 2019 10:13
Printing car object properties
console.log(Object.getOwnPropertyDescriptors(car));
// Output
/*{ year:
{ value: '2010',
writable: true,
enumerable: true,
configurable: true },
make:
@moiz-frost
moiz-frost / car.js
Created September 3, 2019 10:11
Creating an object using object.create()
var car = Object.create(Object.prototype, {
year: {
value: '2010',
writable: true,
enumerable: true,
configurable: true },
make: {
value: 'Honda',
writable: true,
enumerable: true,
@moiz-frost
moiz-frost / car.js
Last active September 3, 2019 18:02
Car Object JavaScript
var car = {
year: '2010',
make: 'Honda',
color: 'White',
transmission: 'Manual',
horsePower: 140,
topSpeed: 120
}
@moiz-frost
moiz-frost / ex1.js
Last active September 3, 2019 18:04
JavaScript This
var horsePower = 50;
function printHP() {
console.log(this.horsePower);
}
var car = {
year: '2010',
make: 'Honda',
color: 'White',
@moiz-frost
moiz-frost / primitive_size.c
Created April 7, 2019 08:39
A small program to print out the size of primitive types
#include <stdio.h>
#include <string.h>
int main() {
int i = 123;
float f = 98.6;
double d = 6.022E23;
char c = 'c';
int* iPtr = &i;
@moiz-frost
moiz-frost / basic_ptr_usage.c
Last active December 25, 2019 01:52
Basic pointer usage
#include <stdio.h>
#include <string.h>
int main() {
int val = 123;
int* valPtr = &val;
printf("address of &val = %p\n", &val);
printf("value of val = %d\n", val);
printf("value of valPtr = %p\n", valPtr);