answersLogoWhite

0

You can assign a JavaScript variable to the attribute of an object using the assignment operator (=)

Here's a quick example.

var imageUrl = "image.png";

var img = new Image();

img.src = imageUrl;

The above code would set the source attribute of the object named img as the contents of the variable imageUrl.

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What does java script do?

Javascript is a programming language that is object orientated. that means that it is much better to use if you want to assign given attributes to an object. Javascript is the best for doing object orientated things.


What is the general form for the JavaScript statement used to assign a value to a text box object within a form?

document.formname.textfieldname.value = variable_or_literal


What is a node id?

It is the value of the attribute id of a node. It is used when manipulating the DOM and can be accessed by using the function getElementById() of the document object in JavaScript


How do you shortcut systemoutprintln in javascript?

There is no systemout object in JavaScript. Do you mean Java?


Why use java script?

Javascript is an object orientated programming language and is very nice when assigning attributes to many different objects. the reason its so nice is that all the attributes are not changed. it just changes the attributes that you assign per object.


What are properties in Javascript?

Like other object-oriented languages (JavaScript is technically not 'object-oriented'), JavaScript has objects, those objects have attributes or 'properties' which hold data


What is differences between tags and attribute?

A tag is a declaration of a HTML object whereas an Attribute is a property of an object.


What JavaScript terms are used to describe the actions performed of an object?

JavaScript is an object-oriented language, and like most OO languages, the actions that are performed on an object are referred to as methods. In JavaScript, methods are also sometimes called functions.


Distinguish between Variable and attribute parameters?

Variables are intended for bulk data, while attributes are intended for ancillary data. Another difference is that variables may be multidimensional, while attributes are all scalars or vectors.


How do you create a new obeject in javaScript?

Just about everything in Javascript is an "object" that inherits the prototype of Object, so initializing a variable most likely results in a new object being created. <pre> var obj1 = {}; // preferred method of creating an empty object var obj2 = new Object(); // instantiate new generic object var str = "Hello World"; // Implicit String Object instantiation var another = new String("Hello World"); // String Object var num = 1; // Number object </pre>


Which one is better Attribute or variable?

It depends on what you are trying to describe. These are common words, but in the areas of algebra and statistics, they are terms which need clear definitions. A variable is represented by a symbol with a value that varies. (see related link) Attribute data is data which shows the absence or presence of a characteristic. In quality control, a piece is either acceptable or unacceptable. A car is either new or used. Attribute data can be represented by a binomial variable. Frequently, 0 is off/ no/ absent and 1 is on/yes/ present. A second definition for "attribute" (not attribute data) when used with a particular object. In this case an attribute can be considered a certain quality or characteristic, like the color of a car. I have included a related link.


What attribute of an object is a measure of the object's inertia?

Mass is the attribute of an object that is a measure of the object's inertia. It represents the amount of matter in an object and is a measure of how much an object resists changes in its motion.