i new javascript , getting highly confused.
i created object,
var recipe = {name:"", price:10, details:"", img_path:""};
and created function it's constructor. gives values object's properties,
function recipeinstantiation( name, price, details, img_path){ recipe.name = name; recipe.price = price; recipe.details=details; recipe.img_path = img_path; // dont know return here //maybe return recipe; }
and need pass recipe object reference,
var recipe2 = recipe;
is correct?
objects reference types , class definition should follow javascript language constructs , conventions (i.e use pascal case classes)
go here , learn http://www.w3schools.com/js/js_objects.asp
---------------------------------- //class definition describes recipe function recipe( name, price, details, img_path){ //javascript use keyword define data fields. this.name = name; this.price = price; this.details=details; this.img_path = img_path; } function displayrecipe(recipe){ //display recipe html } ---------------------------------- var newreceipe = new recipe("pasta", 1000, "something", "img/pasta.jpg"); displayrecipe(newreceipe )