Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                //const newObj = new Object();
const newObj = {};

let count = 'noName';

newObj.make = 'Ford';
newObj.model = 'Mustang';
newObj['year'] = 1969;
newObj['year create'] = 1960;
newObj[count] = 'No name';

console.log(newObj);
console.log(newObj.model);
console.log(newObj['year create'])


const newObj2 = {};
newObj2.make = 'Ford';

console.log(newObj2.hasOwnProperty('make')); //true
console.log(newObj2.hasOwnProperty('model')); //false
console.log(newObj2.model); //undefined




const human1 = {
  name: 'Kolja',
  have: 500
};
const human2 = {
  name: 'Sacha',
  have: 1000
};
console.log(human2.have); //1000
human2.have += 300;
console.log(human2['have']); //1300
delete human2.have;
console.log(human2['have']); //undefined

console.log(human1.length); //undefined
console.log(Object.keys(human1).length); //2
console.log(Object.keys(human1)); //[ 'name', 'have' ]


const human3 = {
  name: 'Sacha',
  have: 5000,
  human2: {
    firstName: 'Sveta',
    LastName: 'Ivanova'
  }
};
console.log(human3.human2.firstName); //Sveta
console.log(human3['human2']['firstName']); //Sveta


let name55 = 'Вася';
let isAdmin = true;
let isArr = [4,5,6,7];
let propName = "firstName";
let a = "Мой ";
let b = "Зелёный ";
let c = "Крокодил";
const user55 = {
  name: name55,
  isAdmin,
  isArr,
  [propName]: "John Dou",
  [(a + b + c).toLowerCase()]: "Гена"
};
console.log(user55.name); //Вася
console.log(user55); //{ name: 'Вася', isAdmin: true, isArr: [ 4, 5, 6, 7 ] }
console.log(user55.isArr); //[ 4, 5, 6, 7 ]
console.log(user55.firstName); //"John Dou"
console.log(user55['мой зелёный крокодил']); //'Гена'


let str1 = 'new string';
let str2 = str1.slice(0);
console.log(str1) //new string
console.log(str2) //new string

str1 = 'some else'
console.log(str1) //some else
console.log(str2) //new string


let user96 = { name: 'Вася'};
let visitor = { isAdmin: false, visits: true };
let admin = { isAdmin: true };
// Object.assign(user96, visitor, admin); //копируем в первый
// console.log(user96) //{ name: 'Вася', isAdmin: true, visits: true }

const clone2 = { ...user96, ...visitor, ...admin };
console.log(clone2) //{ name: 'Вася', isAdmin: true, visits: true }

const { name, visits } = clone2;
//const name = clone2.name;
console.log(name) //Вася
console.log(visits) //true



let user94 = {
  name: 'Петя',
  sayHello: function () {
    //console.log('Hello ' + user94.name)
    console.log('Hello ' + this.name)
    console.log(this) //{ name: 'Петя', sayHello: [Function: sayHello] }
  },
  toUpperCase: function () {
    console.log(this.name.toUpperCase())
  }
};
user94.sayHello(); //Hello Петя
user94.toUpperCase(); //петя


(function () {
  //do something
})();

window.onload = function () {
  //do something
};


new String().toUpperCase();


              
            
!
999px

Console