Node.js – util.types.isInt32Array() Method

Node.jsProgrammingServer Side Programming

<p style="">The <strong>util.types.isInt32Array()</strong> method checks whether the passed value is a built-in <strong>Int32Array</strong> instance or not. If the above condition is satisfied, it returns True, else False.</p><h2>Syntax</h2><pre class="result notranslate">util.types.isInt32Array(value)</pre><h2>Parameters</h2><ul class="list"><li><p><strong>value &minus;&nbsp;</strong>This input takes input for the required parameter and checks if it&#39;s an <strong>Int32Array</strong> instance or not. Returns True or False based upon the input value passed.</p></li></ul><h2>Example 1</h2><p>Create a file with name <strong>isInt32Array.js</strong> and copy the below code snippet.</p><p style="">After creating the file, use the following command to run this code and check the output -</p><pre class="result notranslate">node isInt32Array.js</pre><h3 style="">Program Code</h3><!--<p><a href="" target="_blank" rel="nofollow" class="demo"><i class="fa-external-link"></i> Live Demo</a></p>--><pre class="prettyprint notranslate">// util.types.isInt32Array() Demo Example // Importing the util module const util = require(&#39;util&#39;); // Passing normal Int32-Array as input value console.log(&quot;1.&quot; + util.types.isInt32Array(new Int32Array())); // Passing a Array buffer as input console.log(&quot;2.&quot; + util.types.isInt32Array(new ArrayBuffer())); // Passing a Float64 array as input console.log(&quot;3.&quot; + util.types.isInt32Array(new Int16Array()));</pre><h2>Output</h2><pre class="result notranslate">C:\home ode&gt;&gt; node isInt32Array.js 1.true 2.false 3.false</pre><h2>Example 2</h2><!--<p><a href="" target="_blank" rel="nofollow" class="demo"><i class="fa-external-link"></i> Live Demo</a></p>--><pre class="prettyprint notranslate">// util.types.isInt32Array() Demo Example // Importing the util module const util = require(&#39;util&#39;); // Defining int32 array in multiple ways var int32 = new Int32Array(2); int32[0] = 42; var arr = new Int32Array([21,31]); console.log(arr[1]); // From an ArrayBuffer var buffer = new ArrayBuffer(32); var z = new Int32Array(buffer, 0, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; }(); var arr1 = new Int32Array(iterable); // Passing int32 Array with values as input console.log(&quot;1.&quot; + util.types.isInt32Array(int32)); // Passing a int32 array 0th value as input console.log(&quot;2.&quot; + util.types.isInt32Array(arr)); // Passing a int32 array defined by array buffer console.log(&quot;3.&quot; + util.types.isInt32Array(z)); // Passing a int32 array defined by iterable console.log(&quot;4.&quot; + util.types.isInt32Array(arr1));</pre><h2>Output</h2><pre class="result notranslate">C:\home ode&gt;&gt; node isInt32Array.js 31 1.true 2.true 3.true 4.true</pre>
raja
Updated on 16-Aug-2021 11:51:42

Advertisements