//Write a JavaScript program to list the properties of a JavaScript object
var student = {
name: "David Rayy",
sclass: "VI",
rollno: 12
};
for (var properties in student) {
if (student.hasOwnProperty(properties)) {
console.log(properties);
}
}
//Write a JavaScript program to delete the rollno property from the following object. Also print the object before or after deleting the property.
delete student.rollno;
console.log(student);
//write the javascript program to get the length of a javascript object
var me = {
name: "Mehmetcan",
lastName: "Sinir",
age: 29,
job: "software engineer"
};
function getSize(obj) {
var size = 0,
keys;
for (keys in obj) {
if (obj.hasOwnProperty(keys)) {
size++;
}
}
return size;
}
console.log(getSize(me));
// Write a JavaScript program to display the reading status (i.e. display book name, author name and reading status) of the following books.
var library = [{
title: 'Bill Gates',
author: 'The Road Ahead',
readingStatus: true
}, {
title: 'Steve Jobs',
author: 'Walter Isaacson',
readingStatus: true
}, {
title: 'Mockingjay: The Final Book of The Hunger Games',
author: 'Suzanne Collins',
readingStatus: false
}];
function displayStatus() {
var stati = [];
for (var i = 0; i < library.length; i++) {
var text = "for " + library[i].title + " the reading status is " + library[i].readingStatus + /\n\r/;
stati.push(text);
}
return stati;
}
console.log(displayStatus());
//Write a JavaScript program to get the volume of a Cylinder with four decimal places using object classes
//Volume of a cylinder : V = πr(squared)h
function Cylinder(height, diameter) {//at this point the Cylinder constructor has a prototype property, which points to Cylinder.prototype, a prototype Object, from which new object instances created by the Cylinder constructor get their methods from....
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.