PP.toArray

Syntax

toArray(obj: Object);

Parameters

obj. Object to be moved to array.

Description

The toArray method moves an object to array.

Comments

This method returns an array that has the source object as its only element.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create an object and move it to an empty array:

// Determine object
var chartView = {
    chartType: "pie"
};
// Place this object to array
var objects = PP.toArray(chartView);
console.log("Array length: " + objects.length);
console.log("Array elements:");
for (var i in objects) {
    var object = objects[i];
    console.log(object);
};

After executing the example the browser console displays length of the received array and the list of its elements.

Array length: 1

Elements in the array:

Object {chartType: "pie"}

See also:

PP