Constructor
new PropertyObject(value, optionsopt)
- Source:
- Implements:
Name | Type | Description |
---|---|---|
value |
string | any[] | This value is in the array format. |
options ? |
Partial<PropertyObjectState> | options |
Example
var obj = new PropertyObject([100,100,100,0.5], {
"separator" : ",",
"prefix" : "rgba(",
"suffix" : ")"
});
Methods
clone() → {PropertyObject}
create a copy of an instance itself.
Example
const obj1 = new PropertyObject("1,2,3", ",");
const obj2 = obj1.clone();
Returns:
clone
- Type
- PropertyObject
forEach(callback, callback.currentValueopt, callback.indexopt, callback.arrayopt) → {PropertyObject}
- Source:
- See:
-
- MDN Array.forEach() reference to MDN document.
executes a provided function once per array element.
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
callback |
function | Function to execute for each element, taking three arguments
Properties
|
Example
//rgba(100, 100, 100, 0.5)
var obj4 = new PropertyObject([100,100,100,0.5], {
"separator" : ",",
"prefix" : "rgba(",
"suffix" : ")"
});
obj4.forEach(t => {
console.log(t);
}); // => "100,100,100,0.5"
Returns:
An instance itself
- Type
- PropertyObject
get(index) → {Object}
retrieve one of values at the index
Name | Type | Description |
---|---|---|
index |
Number | index |
Example
const obj1 = new PropertyObject("1,2,3", ",");
console.log(obj1.get(0));
// 1
Returns:
one of values at the index
- Type
- Object
join() → {String}
Make Property Object's array to String
Example
//rgba(100, 100, 100, 0.5)
var obj4 = new PropertyObject([100,100,100,0.5], {
"separator" : ",",
"prefix" : "rgba(",
"suffix" : ")"
});
obj4.join(); // => "100,100,100,0.5"
Returns:
Join the elements of an array into a string
- Type
- String
set(index, value) → {PropertyObject}
Set the value at that index
Name | Type | Description |
---|---|---|
index |
Number | index |
value |
Object | text, a number, object to set |
Example
const obj1 = new PropertyObject("1,2,3", ",");
obj1.set(0, 2);
console.log(obj1.toValue());
// 2,2,3
Returns:
An instance itself
- Type
- PropertyObject
size()
the number of values.
Example
const obj1 = new PropertyObject("1,2,3", ",");
console.log(obj1.length);
// 3
toValue() → {String}
Make Property Object to String
Example
//rgba(100, 100, 100, 0.5)
const obj4 = new PropertyObject([100,100,100,0.5], {
"separator" : ",",
"prefix" : "rgba(",
"suffix" : ")",
});
console.log(obj4.toValue());
// "rgba(100,100,100,0.5)"
Returns:
Make Property Object to String
- Type
- String