<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2769472574235259169</id><updated>2023-10-07T10:51:13.376-07:00</updated><category term="Javascript"/><category term="Html"/><category term="Jquery"/><category term="Angularjs"/><category term="Node.js"/><category term="Reactjs"/><category term="Css"/><category term="Asp.net"/><category term="Arrays"/><category term="Php"/><category term="Ajax"/><category term="Dom"/><category term="Promise"/><category term="C#"/><category term="Date"/><category term="Mongodb"/><category term="Performance"/><category term="Filter"/><category term="Forms"/><category term="Google Maps"/><category term="Iframe"/><category term="Image"/><category term="Json"/><category term="Svg"/><category term="Webpack"/><category term="Angular Filters"/><category term="Asp.net Mvc"/><category term="Bootstrap 4"/><category term="Chart.js"/><category term="Class"/><category term="Cookies"/><category term="Deferred"/><category term="Ecmascript 6"/><category term="Ember.js"/><category term="Express"/><category term="File Upload"/><category term="For Loop"/><category term="Geolocation"/><category term="Http"/><category term="Ios"/><category term="Javascript Objects"/><category term="Jquery Select2"/><category term="Jquery Ui"/><category term="Mongoose"/><category term="Object"/><category term="React Native"/><category term="React Redux"/><category term="Recursion"/><category term="Regex"/><category term="Ruby On Rails"/><category term="Safari"/><category term="Select2"/><category term="String"/><category term="Visual Studio"/><category term="Vue.js"/><category term="Web Scraping"/><category term=".net"/><category term="2d"/><category term="Action"/><category term="Aggregation Framework"/><category term="Algorithm"/><category term="Angularfire2"/><category term="Angularjs Controller"/><category term="Angularjs Filter"/><category term="Angularjs Module"/><category term="Angularjs Scope"/><category term="Animation"/><category term="Apache"/><category term="Apple Tv"/><category term="Applet"/><category term="Asp.net Mvc 3"/><category term="Asp.net Mvc 4"/><category term="Asynchronous"/><category term="Attributes"/><category term="Authentication"/><category term="Autocomplete"/><category term="Babeljs"/><category term="Benchmarking"/><category term="Blogs"/><category term="Browser Detection"/><category term="Browserify"/><category term="Callstack"/><category term="Canvas"/><category term="Checkbox"/><category term="Cheerio"/><category term="Children"/><category term="Coffeescript"/><category term="Combinations"/><category term="Concat"/><category term="Conditional"/><category term="Constants"/><category term="Contenteditable"/><category term="Cordova"/><category term="Cryptojs"/><category term="Csrf"/><category term="Css Modules"/><category term="Csv"/><category term="D3.js"/><category term="Datejs"/><category term="Deezer"/><category term="Dialog"/><category term="Django"/><category term="Document.write"/><category term="Domdocument"/><category term="Domino Designer Eclipse"/><category term="Ejs"/><category term="Electron"/><category term="Encryption"/><category term="Environment Variables"/><category term="Es6 Promise"/><category term="Event Tracking"/><category term="Extend"/><category term="Filtering"/><category term="Fine Uploader"/><category term="Firebase"/><category term="Firebug"/><category term="Firefox"/><category term="Firefox Addon"/><category term="Flash"/><category term="Flask"/><category term="Fonts"/><category term="Format"/><category term="Getelementbyid"/><category term="Global Variables"/><category term="Google Analytics"/><category term="Google Api"/><category term="Google Apps Script"/><category term="Google Chrome"/><category term="Google Chrome Devtools"/><category term="Google Cloud Firestore"/><category term="Google Maps Api 3"/><category term="Google Plus"/><category term="Google Plus One"/><category term="Google Sheets"/><category term="Grails"/><category term="Graphicsmagick"/><category term="Handlebars.js"/><category term="Html Escape Characters"/><category term="Html Select"/><category term="Html5 Canvas"/><category term="Http Post"/><category term="Inheritance"/><category term="Input"/><category term="Internet Explorer"/><category term="Internet Explorer 7"/><category term="Iphone"/><category term="Javascript Events"/><category term="Jestjs"/><category term="Jquery Deferred"/><category term="Jquery Tokeninput"/><category term="Jstree"/><category term="Laravel"/><category term="Load"/><category term="Loops"/><category term="Machine Learning"/><category term="Magento"/><category term="Media Queries"/><category term="Memory Management"/><category term="Mobile"/><category term="Model View Controller"/><category term="Monkeypatching"/><category term="Mousedown"/><category term="Mouseup"/><category term="Multer"/><category term="Mysql"/><category term="Netsuite"/><category term="Next.js"/><category term="Normalize"/><category term="Npm"/><category term="Nullreferenceexception"/><category term="Numbers"/><category term="Odometer"/><category term="Onbeforeunload"/><category term="Onscroll"/><category term="Pagination"/><category term="Parameters"/><category term="Parsley"/><category term="Pdf"/><category term="Phantomjs"/><category term="Photo"/><category term="Photoshop"/><category term="Photoshop Script"/><category term="Phpjs"/><category term="Playback"/><category term="Python 2.7"/><category term="R"/><category term="Rails Api"/><category term="React Quill"/><category term="Readfile"/><category term="Redux"/><category term="Redux Thunk"/><category term="Removechild"/><category term="Replace"/><category term="Rest"/><category term="Routes"/><category term="Rtf"/><category term="Runtime Error"/><category term="Sails.js"/><category term="Select"/><category term="Selenium"/><category term="Sequelize.js"/><category term="Server"/><category term="Shadow Dom"/><category term="Shapes"/><category term="Shiny"/><category term="Slider"/><category term="Sorting"/><category term="Split"/><category term="Suitescript2.0"/><category term="Svg Path"/><category term="Swift"/><category term="Tensorflow.js"/><category term="Three.js"/><category term="Time"/><category term="Tracking.js"/><category term="Training Data"/><category term="Triggers"/><category term="Tvml"/><category term="Tvos"/><category term="Twitter Bootstrap"/><category term="Typescript"/><category term="Uiwebview"/><category term="Unicode"/><category term="Unique"/><category term="Updatepanel"/><category term="Validation"/><category term="Vb.net"/><category term="Video"/><category term="Viewport"/><category term="Vue Component"/><category term="Vuejs2"/><category term="Vuetify.js"/><category term="Wait"/><category term="Wamp"/><category term="Web Component"/><category term="Web Services"/><category term="Websocket"/><category term="Windows Phone 8"/><category term="Wkwebview"/><category term="Wordpress"/><category term="Wtforms"/><category term="Xcode"/><category term="Xml"/><category term="Xpages"/><category term="Xul"/><category term="Youtube Api"/><category term="Youtube Data Api"/><category term="Youtube Iframe Api"/><category term="Youtube Javascript Api"/><category term="Zonejs"/><title type='text'>pracasify</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default?start-index=26&amp;max-results=25'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>208</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-1462423654234769670</id><published>2023-10-07T10:50:00.001-07:00</published><updated>2023-10-07T10:50:40.800-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Document.write"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Document.write Nested In Document.write</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have an ad tag that a third party is trying to stuff inside of a &#39;document.write&#39; function and it&#39;s not working because the ad tag itself also contains document.write&#39;s.  Is ther&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;document.write is often concidered a harmful method, as it directly inserts content into the document file itself. You should edit the innerHTML of the tag where you want to insert the code, although I&#39;ve heard that directly using innerHTML isn&#39;t the correct way either. The method is called insertNode, If I&#39;m remembering correctly, but I&#39;m not sure, because I&#39;m usually abstracting this type of problem away using frameworks such as jQuery, where it is as simple as&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;$(&lt;span class=&quot;hljs-string&quot;&gt;&quot;#myelement&quot;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;html&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;&amp;lt;script&amp;gt;...&amp;lt;/script&amp;gt;&quot;&lt;/span&gt;)
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;I hope that some of my fellow SO members can make this post more precise, I&#39;ll look some stuff up myself, but concider this to be my quick answer.&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/1462423654234769670/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/documentwrite-nested-in-documentwrite.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/1462423654234769670'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/1462423654234769670'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/documentwrite-nested-in-documentwrite.html' title='Document.write Nested In Document.write'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-6123781691192103603</id><published>2023-10-07T10:05:00.001-07:00</published><updated>2023-10-07T10:05:22.789-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Google Chrome Devtools"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Why Does Debuggers Give You &quot;undefined Is Not A Function&quot; Instead Of Just Telling You The Name Of The Property/variable That Is Not A Function?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;What is the reason js debuggers gives you &#39;undefined is not a function&#39; instead of just telling you the name of the property/variable that is not a function? example: a = {   aFunc&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;This is going to be changing very soon, it might already be in Canary too.&lt;/p&gt;&lt;p&gt;Improved exception messages: &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://plus.google.com/+AddyOsmani/posts/DdWkiKsvbA2&quot;&gt;https://plus.google.com/+AddyOsmani/posts/DdWkiKsvbA2&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/6123781691192103603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/why-does-debuggers-give-you-undefined.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6123781691192103603'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6123781691192103603'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/why-does-debuggers-give-you-undefined.html' title='Why Does Debuggers Give You &quot;undefined Is Not A Function&quot; Instead Of Just Telling You The Name Of The Property/variable That Is Not A Function?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-806396011021283298</id><published>2023-10-07T09:28:00.001-07:00</published><updated>2023-10-07T09:28:37.708-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Css Modules"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Jestjs"/><category scheme="http://www.blogger.com/atom/ns#" term="Reactjs"/><title type='text'>Css Module @import Fails The Jest Test Suit</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I am using Jest and Enzyme to test my application. I am getting error:  FAIL  app/containers/Navbar/NavbarContainer.test.js   ● Test suite failed to run      app/components/Navba&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;UPDATE who use &lt;strong&gt;&lt;em&gt;create-react-app&lt;/em&gt;&lt;/strong&gt; from feb 2018.
You cannot override the moduleNameMapper in package.json but in jest.config.js it works, unfortunately i havent found any docs about why it does the trick.
So my &lt;strong&gt;&lt;em&gt;jest.config.js&lt;/em&gt;&lt;/strong&gt; look like this:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-java&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;module&lt;/span&gt;.&lt;span class=&quot;hljs-keyword&quot;&gt;exports&lt;/span&gt; = {
...,
  &lt;span class=&quot;hljs-string&quot;&gt;&quot;moduleNameMapper&quot;&lt;/span&gt;: {
    &lt;span class=&quot;hljs-string&quot;&gt;&quot;\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&amp;lt;rootDir&amp;gt;/__mocks__/fileMock.js&quot;&lt;/span&gt;,
    &lt;span class=&quot;hljs-string&quot;&gt;&quot;\\.(scss|sass|css)$&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;identity-obj-proxy&quot;&lt;/span&gt;
  }
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;and it skips scss files and @import quite well.&lt;/p&gt;&lt;p&gt;I added to devDependencies &lt;strong&gt;identity-obj-proxy&lt;/strong&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;Backing my answer i followed &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jestjs.io/docs/en/webpack&quot;&gt;jest webpack&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;So, I&#39;ve found the solution to this problem. I was importing CSS without the extension in my components and Jest was confusing that import with JS file. Solution is instead of importing css like:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; * &lt;span class=&quot;hljs-keyword&quot;&gt;as&lt;/span&gt; styles &lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&#39;./styles&#39;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;you should import it like:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;import&lt;/span&gt; * &lt;span class=&quot;hljs-keyword&quot;&gt;as&lt;/span&gt; styles &lt;span class=&quot;hljs-keyword&quot;&gt;from&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&#39;./styles.css&#39;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;One quick gotcha that I found with this. If you have a jest.config.js file, then you need to set your moduleNameWrapper inside of that config file.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_4&quot;&gt;Solution 4:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;I know this post is old but i solved this issue by adding &lt;code&gt;jest-transform-css&lt;/code&gt; as a devDependency&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_4&quot; class=&quot;hljs language-css&quot;&gt;npm &lt;span class=&quot;hljs-selector-tag&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;--save-dev&lt;/span&gt; jest-&lt;span class=&quot;hljs-attribute&quot;&gt;transform&lt;/span&gt;-css
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_4&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;and then adding the following inside &lt;code&gt;jest.config.js&lt;/code&gt;&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_6&quot; class=&quot;hljs language-less&quot;&gt;&lt;span class=&quot;hljs-attribute&quot;&gt;transform&lt;/span&gt;: {
                &lt;span class=&quot;hljs-string&quot;&gt;&#39;^.+\\.js$&#39;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;babel-jest&#39;&lt;/span&gt;,
                &lt;span class=&quot;hljs-string&quot;&gt;&#39;.+\\.(css|styl|less|sass|scss)$&#39;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;jest-transform-css&#39;&lt;/span&gt;
    }
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_6&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;you can refer to this &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://github.com/facebook/jest/issues/3094&quot;&gt;github issue&lt;/a&gt; for more information&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/806396011021283298/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/css-module-import-fails-jest-test-suit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/806396011021283298'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/806396011021283298'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/css-module-import-fails-jest-test-suit.html' title='Css Module @import Fails The Jest Test Suit'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-8639128550429200270</id><published>2023-10-07T06:21:00.001-07:00</published><updated>2023-10-07T06:21:22.952-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Css"/><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Jquery"/><title type='text'>Position: Sticky Is Not Working With Top Property?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;Position: sticky with bottom:10px on div with class sidebar is working as expected but with property top:10px is not working as expected? With position: sticky with bottom: 10px on&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;In my case, the parent of the sticky element (the sidebar) had a smaller height than the content =&amp;gt; the sticky element wasn&#39;t going down more than the sidebar&#39;s height.&lt;/p&gt;&lt;p&gt;The solution: I made the sidebar&#39;s height equal to the content&#39;s height (using display flex on the content&#39;s and sidebar&#39;s wrapper).&lt;/p&gt;&lt;p&gt;HTML:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;clas&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;container&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;content&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;This initially has a bigger height than sidebar.&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;sidebar&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;sticky&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;CSS:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-css&quot;&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.container&lt;/span&gt; { dislay: flex; } // By using this &lt;span class=&quot;hljs-selector-tag&quot;&gt;I&lt;/span&gt; make the sidebar the same &lt;span class=&quot;hljs-attribute&quot;&gt;height&lt;/span&gt; as the &lt;span class=&quot;hljs-attribute&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.sticky&lt;/span&gt; { &lt;span class=&quot;hljs-attribute&quot;&gt;position&lt;/span&gt;: sticky; &lt;span class=&quot;hljs-attribute&quot;&gt;top&lt;/span&gt;: &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; }
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/8639128550429200270/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/position-sticky-is-not-working-with-top.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8639128550429200270'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8639128550429200270'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/position-sticky-is-not-working-with-top.html' title='Position: Sticky Is Not Working With Top Property?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-6457382107775753819</id><published>2023-10-07T05:53:00.001-07:00</published><updated>2023-10-07T05:53:12.448-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Removechild"/><title type='text'>Remove Multiple Elements With Same Name Using Removechild?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have an elements with multiple elements inside. The elements inside all have the same name. Is there away to have a function remove all of them?  (refer to this question for exam&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Here&#39;s a solution that removes the first level children with the specified name for the parent with the specified id. If you want to go deeper, you can recursively call it on the child elements you get inside (you&#39;ll have to add a &lt;code&gt;parent&lt;/code&gt; parameter as well).&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;function &lt;span class=&quot;hljs-title&quot;&gt;removeChildren&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;&lt;/span&gt;)&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; parentId = &lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;.parentId;
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childName = &lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;.childName;

    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childNodes = document.getElementById(parentId).childNodes;
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; i=childNodes.length&lt;span class=&quot;hljs-number&quot;&gt;-1&lt;/span&gt;;i &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;i--){
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childNode = childNodes[i];
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;(childNode.name == &lt;span class=&quot;hljs-string&quot;&gt;&#39;foo&#39;&lt;/span&gt;){
            childNode.parentNode.removeChild(childNode);
        }
    }
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;And to call it:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-css&quot;&gt;removeChildren({parentId:&lt;span class=&quot;hljs-string&quot;&gt;&#39;div1&#39;&lt;/span&gt;,childName:&lt;span class=&quot;hljs-string&quot;&gt;&#39;foo&#39;&lt;/span&gt;});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;And a &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsfiddle.net/briguy37/U8xkg/&quot;&gt;fiddle&lt;/a&gt; for testing:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;Notes: You can only access the name element dependably in JavaScript when it supported on your element (e.g. NOT on DIVs!). See &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://stackoverflow.com/questions/570641/javascript-cant-find-div-element-by-name&quot;&gt;here&lt;/a&gt; for why.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;UPDATE:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsfiddle.net/briguy37/U8xkg/9/&quot;&gt;Here&lt;/a&gt;&#39;s a solution using className based on our conversation:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-function&quot;&gt;function &lt;span class=&quot;hljs-title&quot;&gt;removeChildren&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;&lt;/span&gt;)&lt;/span&gt;{
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; parentId = &lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;.parentId;
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childName = &lt;span class=&quot;hljs-keyword&quot;&gt;params&lt;/span&gt;.childName;

    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childNodesToRemove = document.getElementById(parentId).getElementsByClassName(&lt;span class=&quot;hljs-string&quot;&gt;&#39;foo&#39;&lt;/span&gt;);
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; i=childNodesToRemove.length&lt;span class=&quot;hljs-number&quot;&gt;-1&lt;/span&gt;;i &amp;gt;= &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;i--){
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; childNode = childNodesToRemove[i];
        childNode.parentNode.removeChild(childNode);
    }
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;&lt;strong&gt;2021 Answer:&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Perhaps there are lots of way to do it, such as &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren&quot;&gt;Element.replaceChildren()&lt;/a&gt;.
I would like to show you an effective solution with &lt;strong&gt;only one redraw &amp;amp; reflow&lt;/strong&gt;&lt;em&gt;supporting all ES6+ browsers&lt;/em&gt;.&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_4&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;removeChildren&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;cssSelector, parentNode&lt;/span&gt;){
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; elements = parentNode.&lt;span class=&quot;hljs-title function_&quot;&gt;querySelectorAll&lt;/span&gt;(cssSelector);
    &lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; fragment = &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;createDocumentFragment&lt;/span&gt;(); 
    fragment.&lt;span class=&quot;hljs-property&quot;&gt;textContent&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&#39; &#39;&lt;/span&gt;;
    fragment.&lt;span class=&quot;hljs-property&quot;&gt;firstChild&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;replaceWith&lt;/span&gt;(...elements);
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_4&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Usage: &lt;code&gt;removeChildren(&#39;.foo&#39;,document.body);&lt;/code&gt;: remove all elements with className &lt;code&gt;foo&lt;/code&gt; in &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;ok this should be easy. First get the parent element:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_8&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; theParent = &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;getElementById&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;notSoHappyFather&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_8&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;then get an array of the nodes that you want to remove:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_9&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; theChildren = theParent.getElementsByName(&lt;span class=&quot;hljs-string&quot;&gt;&quot;unluckyChild&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_9&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Lastly, remove them with a loop:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_10&quot; class=&quot;hljs language-scss&quot;&gt;for (var i = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &amp;lt; theChildren.length; i++)
{
  theParent&lt;span class=&quot;hljs-selector-class&quot;&gt;.removeChild&lt;/span&gt;(theChildren[i]);
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_10&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_4&quot;&gt;Solution 4:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;A sample of your HTML would get you a more complete answer, but one can fairly easy call DOM functions to get the list of children and just remove them. In jQuery, remove all children would be something like this:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_11&quot; class=&quot;hljs language-csharp&quot;&gt;$(&lt;span class=&quot;hljs-string&quot;&gt;&quot;#target &amp;gt; *&quot;&lt;/span&gt;).&lt;span class=&quot;hljs-keyword&quot;&gt;remove&lt;/span&gt;();
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_11&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;or&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_12&quot; class=&quot;hljs language-javascript&quot;&gt; $(&lt;span class=&quot;hljs-string&quot;&gt;&quot;#target&quot;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;html&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_12&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;And, you can see a demo here: &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsfiddle.net/jfriend00/ZBYCh/&quot;&gt;http://jsfiddle.net/jfriend00/ZBYCh/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Or, not using jQuery you could also do:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_13&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;getElementById&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;target&quot;&lt;/span&gt;).&lt;span class=&quot;hljs-property&quot;&gt;innerHTML&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt;;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_13&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;If you&#39;re trying to only remove a subset of the children (and leave others intact), then you need to be more specific how one would determine which children to leave and which to remove. In jQuery, you could use a .find() select or a filter() selector to narrow the list of children to just the children you wanted to target for removal.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/6457382107775753819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/remove-multiple-elements-with-same-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6457382107775753819'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6457382107775753819'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/remove-multiple-elements-with-same-name.html' title='Remove Multiple Elements With Same Name Using Removechild?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-231503888819005149</id><published>2023-10-07T03:30:00.001-07:00</published><updated>2023-10-07T03:30:19.343-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Aggregation Framework"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Mongodb"/><category scheme="http://www.blogger.com/atom/ns#" term="Mongoose"/><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><title type='text'>Is It Possible To Use Query Projection On The Same Collection That Has A $elemmatch Projection?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I understand that you can limit the items in a subcollection array using $elemMatch as a projection. When using it as such it returns all fields of the subdocuments that match rega&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Yes there are two ways to do this. So you can either use the &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;http://docs.mongodb.org/manual/reference/operator/projection/elemMatch/&quot;&gt;&lt;strong&gt;&lt;code&gt;$elemMatch&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; on the projection side as you already have, with slight changes:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-bash&quot;&gt;Model.findById(&lt;span class=&quot;hljs-built_in&quot;&gt;id&lt;/span&gt;,
   { &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments&quot;&lt;/span&gt;: { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-variable&quot;&gt;$elemMatch&lt;/span&gt;&quot;&lt;/span&gt;: {&lt;span class=&quot;hljs-string&quot;&gt;&quot;created.by&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;Jane&quot;&lt;/span&gt; } } },
   &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(err,doc) {
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Or just add to the query portion and use the positional &lt;code&gt;$&lt;/code&gt; operator:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-bash&quot;&gt;Model.findOne(
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;_id&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-built_in&quot;&gt;id&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments.created.by&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;Jane&quot;&lt;/span&gt; },
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments.$&quot;&lt;/span&gt;: 1 },
    &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(err,doc) {
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Either way is perfectly valid.&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;If you wanted something a little more involved than that, you can use the &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;http://docs.mongodb.org/manual/reference/method/db.collection.aggregate/&quot;&gt;&lt;strong&gt;&lt;code&gt;.aggregate()&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; method and it&#39;s &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;http://docs.mongodb.org/manual/reference/operator/aggregation/project/&quot;&gt;&lt;strong&gt;&lt;code&gt;$project&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; operator instead:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_6&quot; class=&quot;hljs language-php&quot;&gt;Model.aggregate([
    &lt;span class=&quot;hljs-comment&quot;&gt;// Still match the document&lt;/span&gt;
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$match&lt;/span&gt;&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;_id&quot;&lt;/span&gt;: id, &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments.created.by&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;Jane&quot;&lt;/span&gt; },

    &lt;span class=&quot;hljs-comment&quot;&gt;// Unwind the array&lt;/span&gt;
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$unwind&lt;/span&gt;&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$comments&lt;/span&gt;&quot;&lt;/span&gt; },

    &lt;span class=&quot;hljs-comment&quot;&gt;// Only match elements, there can be more than 1&lt;/span&gt;
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$match&lt;/span&gt;&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;_id&quot;&lt;/span&gt;: id, &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments.created.by&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;Jane&quot;&lt;/span&gt; },

    &lt;span class=&quot;hljs-comment&quot;&gt;// Project only what you want&lt;/span&gt;
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$project&lt;/span&gt;&quot;&lt;/span&gt;: {
        &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments&quot;&lt;/span&gt;: {
            &lt;span class=&quot;hljs-string&quot;&gt;&quot;body&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$comments&lt;/span&gt;.body&quot;&lt;/span&gt;,
            &lt;span class=&quot;hljs-string&quot;&gt;&quot;by&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$comments&lt;/span&gt;.created.by&quot;&lt;/span&gt;
        }
    }},

    &lt;span class=&quot;hljs-comment&quot;&gt;// Group back each document with the array if you want to&lt;/span&gt;
    { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$group&lt;/span&gt;&quot;&lt;/span&gt;: {
        &lt;span class=&quot;hljs-string&quot;&gt;&quot;_id&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$_id&lt;/span&gt;&quot;&lt;/span&gt;,
        &lt;span class=&quot;hljs-string&quot;&gt;&quot;comments&quot;&lt;/span&gt;: { &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$push&lt;/span&gt;&quot;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;span class=&quot;hljs-subst&quot;&gt;$comments&lt;/span&gt;&quot;&lt;/span&gt; }
    }}
],
&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;err,result&lt;/span&gt;) &lt;/span&gt;{
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_6&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;So the aggregation framework can be used for a lot more than simply aggregating results. It&#39;s &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;http://docs.mongodb.org/manual/reference/operator/aggregation/project/&quot;&gt;&lt;strong&gt;&lt;code&gt;$project&lt;/code&gt;&lt;/strong&gt;&lt;/a&gt; operator gives you more flexibility than is available to projection using &lt;code&gt;.find()&lt;/code&gt;. It also allows you to filter and return multiple array results, which is also something that cannot be done with projection in &lt;code&gt;.find()&lt;/code&gt;.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/231503888819005149/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/is-it-possible-to-use-query-projection.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/231503888819005149'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/231503888819005149'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/is-it-possible-to-use-query-projection.html' title='Is It Possible To Use Query Projection On The Same Collection That Has A $elemmatch Projection?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-2040633249825709409</id><published>2023-10-07T02:34:00.001-07:00</published><updated>2023-10-07T02:34:27.960-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Jstree"/><title type='text'>I Am Using Jstree And Jstree Grid And Data In My Second Column Disppears</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have one column in jsTree Grid representing my tree. The second column is used for displaying &#39;tags&#39; associated with each node. It is displaying great until I click another level&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;The problem is that the jsTreeGrid plugin redraws the cells when you expand a node. Since you only append your tags during the &quot;loaded&quot; and &quot;select_cell&quot; events, the tags disappear.&lt;/p&gt;&lt;p&gt;You can workaround this by re-appending the tags on more events:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-bash&quot;&gt;.&lt;span class=&quot;hljs-built_in&quot;&gt;bind&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;open_node.jstree create_node.jstree clean_node.jstree change_node.jstree&quot;&lt;/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (event, data) { 
    doDisplayTags(mapNameTag);
})
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/2040633249825709409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/i-am-using-jstree-and-jstree-grid-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/2040633249825709409'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/2040633249825709409'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/i-am-using-jstree-and-jstree-grid-and.html' title='I Am Using Jstree And Jstree Grid And Data In My Second Column Disppears'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-6066906591323464083</id><published>2023-10-06T21:59:00.001-07:00</published><updated>2023-10-06T21:59:28.991-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Callstack"/><category scheme="http://www.blogger.com/atom/ns#" term="Class"/><category scheme="http://www.blogger.com/atom/ns#" term="Inheritance"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Recursion"/><title type='text'>Maximum Call Stack Size Exceeded - No Apparent Recursion</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I&#39;ve spent about 12 hours looking through this code, and fiddling with it, trying to find out where there&#39;s a recursion problem because I&#39;m getting the, &#39;maximum call stack size ex&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-kotlin&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.parent.draw.call(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;,ctx);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;p&gt;is your problem. On a &lt;code&gt;pip&lt;/code&gt; object, the parent will be &lt;code&gt;circle.prototype&lt;/code&gt;. So when you now call &lt;code&gt;spot.draw()&lt;/code&gt;, it will call &lt;code&gt;spot.parent.draw.call(spot)&lt;/code&gt;, where &lt;code&gt;this.parent&lt;/code&gt; is still the &lt;code&gt;circle.prototype&lt;/code&gt;…&lt;/p&gt;&lt;p&gt;You will need to explicitly invoke &lt;code&gt;drawableItem.prototype.draw.call(this)&lt;/code&gt; from &lt;code&gt;circle.prototype.draw&lt;/code&gt;. Btw, you should &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://stackoverflow.com/q/12592913/1048572&quot;&gt;not use &lt;code&gt;new&lt;/code&gt; for the prototype chain&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Why would you write code like that? It&#39;s so difficult to understand and debug. When I&#39;m creating lots of classes I usually use &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://github.com/javascript/augment&quot;&gt;&lt;code&gt;augment&lt;/code&gt;&lt;/a&gt; to structure my code. This is how I would rewrite your code:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_11&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Point&lt;/span&gt; = &lt;span class=&quot;hljs-title class_&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;augment&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
    &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;constructor&lt;/span&gt; = &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;x, y&lt;/span&gt;) {
        &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;x&lt;/span&gt; = x;
        &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;y&lt;/span&gt; = y;
    };
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_11&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Using &lt;code&gt;augment&lt;/code&gt; you can create classes cleanly. For example your &lt;code&gt;drawableItem&lt;/code&gt; class could be restructured as follows:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_14&quot; class=&quot;hljs language-kotlin&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; DrawableItem = Object.augment(function () {
    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt; = function () {
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.size = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.lineWidth = &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;;
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.dependencies = [];
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.center = new Point(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
    };

    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.changeSize = function (toSize) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; fromSize = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.size;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; ratio = toSize / fromSize;
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.size = toSize;

        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dependencies = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.dependencies;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; length = dependencies.length;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; index = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (index &amp;lt; length) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dependency = dependencies[index++];
            dependency.changeSize(dependency.size * ratio);
        }
    };

    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.moveTo = function (x, y) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; center = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.center;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dx = x - center.x;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dy = y - center.y;
        center.x = x;
        center.y = y;

        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dependencies = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.dependencies;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; length = dependencies.length;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; index = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (index &amp;lt; length) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dependency = dependencies[index++];
            &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; center = dependency.center;

            dependency.moveTo(center.x + dx, center.y + dy);
        }
    };

    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.draw = function (context) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; dependencies = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.dependencies;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; length = dependencies.length;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; index = &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;

        &lt;span class=&quot;hljs-keyword&quot;&gt;while&lt;/span&gt; (index &amp;lt; length) dependencies[index++].draw(context);
    };
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_14&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Inheritance is also very simple. For example you can restructure your &lt;code&gt;circle&lt;/code&gt; and &lt;code&gt;pip&lt;/code&gt; classes as follows:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_17&quot; class=&quot;hljs language-kotlin&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; Circle = DrawableItem.augment(function (base) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt; = function (filled) {
        base.&lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;.call(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;);
        &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.filled = filled;
    };

    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.draw = function (context) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; center = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.center;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; x = center.x;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; y = center.y;

        context.moveTo(x, y);

        context.beginPath();
        context.arc(x, y, &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.size, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt; * Math.PI);
        context.closePath();

        context.lineWidth = &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.lineWidth;
        context[&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.filled ? &lt;span class=&quot;hljs-string&quot;&gt;&quot;fill&quot;&lt;/span&gt; : &lt;span class=&quot;hljs-string&quot;&gt;&quot;stroke&quot;&lt;/span&gt;]();
        base.draw.call(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;, context);
    };
});

&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; Pip = Circle.augment(function (base) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt; = function () {
        base.&lt;span class=&quot;hljs-keyword&quot;&gt;constructor&lt;/span&gt;.call(&lt;span class=&quot;hljs-keyword&quot;&gt;this&lt;/span&gt;, &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;);
    };
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_17&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Now that you&#39;ve created all your classes you can finally get down to the drawing:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_18&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;addEventListener&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;DOMContentLoaded&quot;&lt;/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; canvas = &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;getElementById&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;myCanvas&quot;&lt;/span&gt;);
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; context = canvas.&lt;span class=&quot;hljs-title function_&quot;&gt;getContext&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;2d&quot;&lt;/span&gt;);
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; drawableArea = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;DrawableItem&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; spot = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Pip&lt;/span&gt;;

    spot.&lt;span class=&quot;hljs-title function_&quot;&gt;changeSize&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;20&lt;/span&gt;);
    drawableArea.&lt;span class=&quot;hljs-property&quot;&gt;dependencies&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;push&lt;/span&gt;(spot);
    &lt;span class=&quot;hljs-variable language_&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;addEventListener&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;resize&quot;&lt;/span&gt;, drawScreen, &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;);

    &lt;span class=&quot;hljs-title function_&quot;&gt;drawScreen&lt;/span&gt;();

    &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;drawScreen&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; width = canvas.&lt;span class=&quot;hljs-property&quot;&gt;width&lt;/span&gt; = &lt;span class=&quot;hljs-variable language_&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;innerWidth&lt;/span&gt;;
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; height = canvas.&lt;span class=&quot;hljs-property&quot;&gt;height&lt;/span&gt; = &lt;span class=&quot;hljs-variable language_&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;innerHeight&lt;/span&gt;;
        spot.&lt;span class=&quot;hljs-title function_&quot;&gt;moveTo&lt;/span&gt;(width / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, height / &lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;);
        drawableArea.&lt;span class=&quot;hljs-title function_&quot;&gt;draw&lt;/span&gt;(context);
    }
}, &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_18&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;We&#39;re done. See the demo for yourself: &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsfiddle.net/b5vNk/&quot;&gt;http://jsfiddle.net/b5vNk/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Not only have we made your code more readable, understandable and maintainable but we have also solved your recursion problem.&lt;/p&gt;&lt;p&gt;As Bergi mentioned the problem was with the statement &lt;code&gt;this.parent.draw.call(this,ctx)&lt;/code&gt; in the &lt;code&gt;circle.prototype.draw&lt;/code&gt; function. Since &lt;code&gt;spot.parent&lt;/code&gt; is &lt;code&gt;circle.prototype&lt;/code&gt; the &lt;code&gt;this.parent.draw.call(this,ctx)&lt;/code&gt; statement is equivalent to &lt;code&gt;circle.prototype.draw.call(this,ctx)&lt;/code&gt;. As you can see the &lt;code&gt;circle.prototype.draw&lt;/code&gt; function now calls itself recursively until it exceeds the maximum recursion depth and throws an error.&lt;/p&gt;&lt;p&gt;The &lt;code&gt;augment&lt;/code&gt; library solves this problem elegantly. Instead of having to create a &lt;code&gt;parent&lt;/code&gt; property on every prototype when you augment a class &lt;code&gt;augment&lt;/code&gt; provides you the &lt;code&gt;prototype&lt;/code&gt; of that class as a argument (we call it &lt;code&gt;base&lt;/code&gt;):&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_31&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;DerivedClass&lt;/span&gt; = &lt;span class=&quot;hljs-title class_&quot;&gt;BaseClass&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;augment&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;base&lt;/span&gt;) {
    &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(base === &lt;span class=&quot;hljs-title class_&quot;&gt;BaseClass&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;); &lt;span class=&quot;hljs-comment&quot;&gt;// true&lt;/span&gt;
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_31&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;base&lt;/code&gt; argument should be treated as a constant. Because it&#39;s a constant &lt;code&gt;base.draw.call(this, context)&lt;/code&gt; in the &lt;code&gt;Circle&lt;/code&gt; class above will always be equivalent to &lt;code&gt;DrawableItem.prototype.draw.call(this, context)&lt;/code&gt;. Hence you will never have unwanted recursion. Unlike &lt;code&gt;this.parent&lt;/code&gt; the &lt;code&gt;base&lt;/code&gt; argument will alway point to the correct prototype.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Bergi&#39;s answer is correct, if you don&#39;t want to hard code the parent name multiple times you could use a helper function to set up inheritance:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_38&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;inherits&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;Child,Parent&lt;/span&gt;){
  &lt;span class=&quot;hljs-title class_&quot;&gt;Child&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;=&lt;span class=&quot;hljs-title class_&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;create&lt;/span&gt;(&lt;span class=&quot;hljs-title class_&quot;&gt;Parent&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;);
  &lt;span class=&quot;hljs-title class_&quot;&gt;Child&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;parent&lt;/span&gt;=&lt;span class=&quot;hljs-title class_&quot;&gt;Parent&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;;
  &lt;span class=&quot;hljs-title class_&quot;&gt;Child&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;constructor&lt;/span&gt;=&lt;span class=&quot;hljs-title class_&quot;&gt;Child&lt;/span&gt;;
};
&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;DrawableItem&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
  &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;DrawableItem&quot;&lt;/span&gt;;
}
&lt;span class=&quot;hljs-title class_&quot;&gt;DrawableItem&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;changeSize&lt;/span&gt; = &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;newSize&lt;/span&gt;){
  &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;changeSize from DrawableItem&quot;&lt;/span&gt;);
  &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;invoking object is:&quot;&lt;/span&gt;,&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;name&lt;/span&gt;);
}
&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;Circle&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;isFilledCircle&lt;/span&gt;){
    &lt;span class=&quot;hljs-title class_&quot;&gt;Circle&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;parent&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;constructor&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;call&lt;/span&gt;(&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;);
    &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;Circle&quot;&lt;/span&gt;;&lt;span class=&quot;hljs-comment&quot;&gt;//override name&lt;/span&gt;
}
&lt;span class=&quot;hljs-title function_&quot;&gt;inherits&lt;/span&gt;(&lt;span class=&quot;hljs-title class_&quot;&gt;Circle&lt;/span&gt;,&lt;span class=&quot;hljs-title class_&quot;&gt;DrawableItem&lt;/span&gt;);
&lt;span class=&quot;hljs-title class_&quot;&gt;Circle&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;prototype&lt;/span&gt;&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;changeSize&lt;/span&gt; = &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;newSize&lt;/span&gt;){
  &lt;span class=&quot;hljs-title class_&quot;&gt;Circle&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;parent&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;changeSize&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;call&lt;/span&gt;(&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;);
  &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;and some more from circle&quot;&lt;/span&gt;);
};
&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;Pip&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;size&lt;/span&gt;){
    &lt;span class=&quot;hljs-title class_&quot;&gt;Pip&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;parent&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;constructor&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;call&lt;/span&gt;(&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;,&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;);
    &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;Pip&quot;&lt;/span&gt;;
}
&lt;span class=&quot;hljs-title function_&quot;&gt;inherits&lt;/span&gt;(&lt;span class=&quot;hljs-title class_&quot;&gt;Pip&lt;/span&gt;,&lt;span class=&quot;hljs-title class_&quot;&gt;Circle&lt;/span&gt;);

&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; spot = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Pip&lt;/span&gt;();
spot.&lt;span class=&quot;hljs-title function_&quot;&gt;changeSize&lt;/span&gt;();
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_38&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;For a polyfill on Object.create look &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create?redirectlocale=en-US&amp;amp;redirectslug=JavaScript/Reference/Global_Objects/Object/create#Polyfill&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/6066906591323464083/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/maximum-call-stack-size-exceeded-no.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6066906591323464083'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6066906591323464083'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/maximum-call-stack-size-exceeded-no.html' title='Maximum Call Stack Size Exceeded - No Apparent Recursion'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7604897643345644434</id><published>2023-10-06T21:35:00.001-07:00</published><updated>2023-10-06T21:35:09.391-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>How To Combine Two Data Into One In Javascript?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I&#39;m getting the data from two different place. After getting the data, how to merge two into one. For example; //data structure looks like: //from url1 {     &#39;data&#39;: [&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;try this&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; url1 = &lt;span class=&quot;hljs-string&quot;&gt;&quot;https://reqres.in/api/users&quot;&lt;/span&gt;; 
     &lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; url2 = &lt;span class=&quot;hljs-string&quot;&gt;&quot;https://reqres.in/api/users?page=2&quot;&lt;/span&gt;;

    &lt;span class=&quot;hljs-comment&quot;&gt;//store the data from url1&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;getData&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;){

        
    &lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; response1 = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(url1);
    &lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; response2 = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(url2);

    
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (response1.&lt;span class=&quot;hljs-property&quot;&gt;status&lt;/span&gt; === &lt;span class=&quot;hljs-number&quot;&gt;200&lt;/span&gt; &amp;amp;&amp;amp; response2.&lt;span class=&quot;hljs-property&quot;&gt;status&lt;/span&gt; === &lt;span class=&quot;hljs-number&quot;&gt;200&lt;/span&gt;) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data1 = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; response1.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;();
        &lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data2 = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; response2.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;();
        &lt;span class=&quot;hljs-comment&quot;&gt;// handle data&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data = [...data1.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;, ...data2.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;];  &lt;span class=&quot;hljs-comment&quot;&gt;// it only get the data from data1, the data2 is missing&lt;/span&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(data); 
    }




    }

    &lt;span class=&quot;hljs-title function_&quot;&gt;getData&lt;/span&gt;();&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;My approach would be:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;Put the urls in an array.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Use &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await&quot;&gt;&lt;code&gt;async/await&lt;/code&gt;&lt;/a&gt; to make the process easier.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map&quot;&gt;&lt;code&gt;map&lt;/code&gt;&lt;/a&gt; over the array to create a new array of promises.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;code&gt;await&lt;/code&gt; until all the promises have been resolved.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Parse the JSON to JS objects.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Return an object that combines all the data properties of the objects within one data property with &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap&quot;&gt;&lt;code&gt;flatMap&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_5&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; urls = [&lt;span class=&quot;hljs-string&quot;&gt;&#39;https://reqres.in/api/users&#39;&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&#39;https://reqres.in/api/users?page=2&#39;&lt;/span&gt;];

&lt;span class=&quot;hljs-comment&quot;&gt;// Pass in the array to the function&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;getData&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;urls&lt;/span&gt;) {

  &lt;span class=&quot;hljs-keyword&quot;&gt;try&lt;/span&gt; {

    &lt;span class=&quot;hljs-comment&quot;&gt;// `map` over the array to create an array of promises&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; promises = urls.&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;url&lt;/span&gt; =&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(url));

    &lt;span class=&quot;hljs-comment&quot;&gt;// Wait for the responses to return&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; responses = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Promise&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;all&lt;/span&gt;(promises);

    &lt;span class=&quot;hljs-comment&quot;&gt;// Use `map` again to parse the JSON&lt;/span&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// `.json()` returns a new promise so we have to&lt;/span&gt;&lt;span class=&quot;hljs-comment&quot;&gt;//  use `Promise.all` again to wait for them all to resolve&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data = &lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Promise&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;all&lt;/span&gt;(responses.&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;res&lt;/span&gt; =&amp;gt;&lt;/span&gt; res.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;()));

    &lt;span class=&quot;hljs-comment&quot;&gt;// Finally return an object that combines the data&lt;/span&gt;&lt;span class=&quot;hljs-comment&quot;&gt;// within one data property&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; { &lt;span class=&quot;hljs-attr&quot;&gt;data&lt;/span&gt;: data.&lt;span class=&quot;hljs-title function_&quot;&gt;flatMap&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;obj&lt;/span&gt; =&amp;gt;&lt;/span&gt; obj.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;) };
  
  } &lt;span class=&quot;hljs-keyword&quot;&gt;catch&lt;/span&gt;(err) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; err;
  }

}

(&lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt; () =&amp;gt; {
  &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;getData&lt;/span&gt;(urls));
})();&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_5&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;You are trying to merge promises resolving to arrays. You have to await the promise and can use the &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax&quot;&gt;spread operator&lt;/a&gt; to merge the elements. You have to use the &lt;code&gt;json&lt;/code&gt; method to read and parse the response. It also returns a promise. I wrapped the &lt;code&gt;await&lt;/code&gt;s in an async &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/IIFE&quot;&gt;IIFE&lt;/a&gt; because you can&#39;t use &lt;code&gt;await&lt;/code&gt; in a non-async functions or in global scope.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_9&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; url1 = &lt;span class=&quot;hljs-string&quot;&gt;&quot;https://reqres.in/api/users&quot;&lt;/span&gt;; 
&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; url2 = &lt;span class=&quot;hljs-string&quot;&gt;&quot;https://reqres.in/api/users?page=2&quot;&lt;/span&gt;;

&lt;span class=&quot;hljs-comment&quot;&gt;// store promise to data from url1&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data1 = &lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(url1)
              .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;result&lt;/span&gt; =&amp;gt;&lt;/span&gt; result.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;())
              .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;result&lt;/span&gt; =&amp;gt;&lt;/span&gt; result.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;);

&lt;span class=&quot;hljs-comment&quot;&gt;// store promise to data from url2&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data2 = &lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(url2)
              .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;result&lt;/span&gt; =&amp;gt;&lt;/span&gt; result.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;())
              .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;result&lt;/span&gt; =&amp;gt;&lt;/span&gt; result.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;);

(&lt;span class=&quot;hljs-keyword&quot;&gt;async&lt;/span&gt; () =&amp;gt; {
  &lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data = [...&lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; data1, ...&lt;span class=&quot;hljs-keyword&quot;&gt;await&lt;/span&gt; data2];
  &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(data); 
})();&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_9&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_4&quot;&gt;Solution 4:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;To combine all the elements of 2 arrays together, you can use the spread operator like&lt;/p&gt;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_10&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data = [...data1.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;, ...data2.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;];
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_10&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;or you can use the &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat&quot;&gt;&lt;code&gt;concat&lt;/code&gt;&lt;/a&gt; function:&lt;/p&gt;&lt;pre class=&quot;lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_12&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; data = data1.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;concat&lt;/span&gt;(data2.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_12&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_5&quot;&gt;Solution 5:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;The way you fetch data is not complete.&lt;/p&gt;&lt;p&gt;This code below will give you a Response object that contain some infomation about response you got.&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_13&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;https://reqres.in/api/users&#39;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;response&lt;/span&gt; =&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(response))
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_13&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;But to retrieve data correctly, You should do like this:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_14&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;https://reqres.in/api/users&#39;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;response&lt;/span&gt; =&amp;gt;&lt;/span&gt; response.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;/span&gt;()).&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;data&lt;/span&gt; =&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(data))
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_14&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7604897643345644434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-combine-two-data-into-one-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7604897643345644434'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7604897643345644434'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-combine-two-data-into-one-in.html' title='How To Combine Two Data Into One In Javascript?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-5029401566318392338</id><published>2023-10-06T21:10:00.001-07:00</published><updated>2023-10-06T21:10:39.289-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Angularjs"/><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Getting An Image To Appear On A Popup Window With Angular Js</title><content type='html'>&lt;div class=&quot;question&quot;&gt;This is my first post on StackOverflow and I am teaching myself Angular, so I am a beginner and currently confused. I am creating a webpage with Angular and one of the pages involv&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;In your instructionController.js -&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-swift&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.showDetails &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt; function(id) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;; i &lt;span class=&quot;hljs-operator&quot;&gt;&amp;lt;&lt;/span&gt; this.steps.length; i&lt;span class=&quot;hljs-operator&quot;&gt;++&lt;/span&gt;) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.steps[i].id &lt;span class=&quot;hljs-operator&quot;&gt;===&lt;/span&gt; id) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.name &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.steps[i].name;
            &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.step &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.steps[i].step;
            &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.description &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.steps[i].description;



    ## &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.figure &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.steps[i].figure;
    ## &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.alt &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.alt[i].alt;
    ## &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.imageCaption &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.imageCaption[i].imageCaption

            &lt;span class=&quot;hljs-keyword&quot;&gt;self&lt;/span&gt;.showValue &lt;span class=&quot;hljs-operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
        }
    }
};
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;The lines starting with &lt;strong&gt;##&lt;/strong&gt; are the ones you need to add So basically you forgot to loop the above highlighted lines.
Hope this helps. &lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/5029401566318392338/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/getting-image-to-appear-on-popup-window.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/5029401566318392338'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/5029401566318392338'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/getting-image-to-appear-on-popup-window.html' title='Getting An Image To Appear On A Popup Window With Angular Js'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-3287419527381754290</id><published>2023-10-06T20:47:00.001-07:00</published><updated>2023-10-06T20:47:24.237-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Json"/><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="Reactjs"/><title type='text'>Need To Find Or Count Duplicates In Multidimensional Array</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I need to count the no of duplicates in an multidimensional array and give alert if duplicates found. Arr =[[2,&#39;sk&#39;],[3,&#39;df&#39;],[7,&#39;uz&#39;],[3,&#39;df&#39;],[7,&#39;gh&#39;]] Suggestions: Count can be&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;My &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://stackoverflow.com/a/67953044/14454939&quot;&gt;answer&lt;/a&gt; from the original question (except that I&#39;ve got three items like &lt;code&gt;[3, &quot;df&quot;]&lt;/code&gt; in the input array) is:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; input = [
  [&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;gh&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;21&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;1sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;]
];

&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; duplicate_count = input.&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt; - &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Set&lt;/span&gt;( input.&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-title class_&quot;&gt;JSON&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;stringify&lt;/span&gt;) ).&lt;span class=&quot;hljs-property&quot;&gt;size&lt;/span&gt;;

&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(duplicate_count);&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;If the count for &lt;code&gt;[[3,&quot;df&quot;],[3,&quot;df&quot;],[3,&quot;df&quot;]]&lt;/code&gt; should be one instead of two then perhaps something like:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; input = [
  [&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;gh&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;5&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;21&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;1sk&quot;&lt;/span&gt;], [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;]
];

&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; duplicate_count = [
  ...input
    .&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-title class_&quot;&gt;JSON&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;stringify&lt;/span&gt;)
    .&lt;span class=&quot;hljs-title function_&quot;&gt;reduce&lt;/span&gt;( &lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;acc, v&lt;/span&gt;) =&amp;gt;&lt;/span&gt; acc.&lt;span class=&quot;hljs-title function_&quot;&gt;set&lt;/span&gt;(v, (acc.&lt;span class=&quot;hljs-title function_&quot;&gt;get&lt;/span&gt;(v) || &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;), &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Map&lt;/span&gt;() )
    .&lt;span class=&quot;hljs-title function_&quot;&gt;values&lt;/span&gt;()
].&lt;span class=&quot;hljs-title function_&quot;&gt;filter&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;v&lt;/span&gt;) =&amp;gt;&lt;/span&gt; v &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;).&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt;;

&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(duplicate_count);&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;You could &lt;code&gt;map&lt;/code&gt; to concatenate the numbers and strings, then &lt;code&gt;sort&lt;/code&gt;. Finally, &lt;code&gt;reduce&lt;/code&gt; the array to the duplicates count.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_7&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; input = [
  [&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;gh&quot;&lt;/span&gt;],
  [&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],
];

&lt;span class=&quot;hljs-keyword&quot;&gt;const&lt;/span&gt; result = input
  .&lt;span class=&quot;hljs-title function_&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;[number, string]&lt;/span&gt;) =&amp;gt;&lt;/span&gt; number + string)
  .&lt;span class=&quot;hljs-title function_&quot;&gt;sort&lt;/span&gt;()
  .&lt;span class=&quot;hljs-title function_&quot;&gt;reduce&lt;/span&gt;(
    &lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;acc, cur, i, { [i - &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]: last }&lt;/span&gt;) =&amp;gt;&lt;/span&gt; (cur === last ? acc + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt; : acc),
    &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;
  );

&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;`Count: &lt;span class=&quot;hljs-subst&quot;&gt;${result}&lt;/span&gt;&lt;span class=&quot;hljs-subst&quot;&gt;${result &amp;amp;&amp;amp; &lt;span class=&quot;hljs-string&quot;&gt;&#39; Alert duplicate data found&#39;&lt;/span&gt;}&lt;/span&gt;`&lt;/span&gt;);&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_7&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_8&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; arr =[[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;gh&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;]]
    
    &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;getNumDupes&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;a&lt;/span&gt;) {
       &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; a.&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt;-
    arr.&lt;span class=&quot;hljs-title function_&quot;&gt;reduce&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;b,a&lt;/span&gt;)=&amp;gt;&lt;/span&gt;{&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (!b.&lt;span class=&quot;hljs-title function_&quot;&gt;includes&lt;/span&gt;(a.&lt;span class=&quot;hljs-title function_&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt;))) b.&lt;span class=&quot;hljs-title function_&quot;&gt;push&lt;/span&gt;(a.&lt;span class=&quot;hljs-title function_&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;&quot;&lt;/span&gt;)); &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; b;},[]).&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt; 
    }
    
    &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-title function_&quot;&gt;getNumDupes&lt;/span&gt;(arr) + &lt;span class=&quot;hljs-string&quot;&gt;&#39; duplicates found&#39;&lt;/span&gt;);&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_8&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_4&quot;&gt;Solution 4:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;You can use &lt;code&gt;forEach&lt;/code&gt; to iterate the array and then filter and check length if found more than 1, set an entry into Map which holds a key value pair and will keep 1 entry for same key and then can check the size.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_10&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; arr =[[&lt;span class=&quot;hljs-number&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;sk&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;uz&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;df&quot;&lt;/span&gt;],[&lt;span class=&quot;hljs-number&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;hljs-string&quot;&gt;&quot;gh&quot;&lt;/span&gt;]];

&lt;span class=&quot;hljs-keyword&quot;&gt;let&lt;/span&gt; map = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Map&lt;/span&gt;();
arr.&lt;span class=&quot;hljs-title function_&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;e1&lt;/span&gt; =&amp;gt;&lt;/span&gt; 
                 arr.&lt;span class=&quot;hljs-title function_&quot;&gt;filter&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;e2&lt;/span&gt; =&amp;gt;&lt;/span&gt; e1[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]===e2[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;] &amp;amp;&amp;amp; e1[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]===e2[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]).&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt; &amp;gt; &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;
                 ? map.&lt;span class=&quot;hljs-title function_&quot;&gt;set&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;`&lt;span class=&quot;hljs-subst&quot;&gt;${e1[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]}&lt;/span&gt;-&lt;span class=&quot;hljs-subst&quot;&gt;${e1[&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;]}&lt;/span&gt;`&lt;/span&gt;,&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) 
                 : &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;/span&gt;
            );

&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;`&lt;span class=&quot;hljs-subst&quot;&gt;${map.size}&lt;/span&gt; duplicate found`&lt;/span&gt;);&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_10&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/3287419527381754290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/need-to-find-or-count-duplicates-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/3287419527381754290'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/3287419527381754290'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/need-to-find-or-count-duplicates-in.html' title='Need To Find Or Count Duplicates In Multidimensional Array'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7933730580166752187</id><published>2023-10-06T19:26:00.001-07:00</published><updated>2023-10-06T19:26:26.129-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Photoshop"/><category scheme="http://www.blogger.com/atom/ns#" term="Photoshop Script"/><title type='text'>Photoshop Move Layer Along Y-axis</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I&#39;m working on a script that will move a layer, right, left, up, or down. This depends upon which edge of the layer is inside the canvas. I&#39;ve managed to get the layer moving left&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;The first thing you probably want to do in a situation like this is to check &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop-cc-javascript-ref-2019.pdf&quot;&gt;the documentation&lt;/a&gt;. For &lt;code&gt;.translate()&lt;/code&gt; we can find the following:&lt;/p&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://i.stack.imgur.com/YACDD.png&quot;&gt;&lt;img alt=&quot;enter image description here&quot; src=&quot;https://i.stack.imgur.com/YACDD.png&quot;&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;so to move horizontally we would use &lt;code&gt;deltaX&lt;/code&gt; and to move vertically &lt;code&gt;deltaY&lt;/code&gt;, in your code you&#39;re giving to &lt;code&gt;.translate()&lt;/code&gt; only &lt;code&gt;deltaX&lt;/code&gt;, so as expected your layer is being moved horizontally. To fix this pass &lt;code&gt;0&lt;/code&gt; as a first argument and your &lt;code&gt;Height-Y1&lt;/code&gt; as a second one:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_7&quot; class=&quot;hljs language-css&quot;&gt;activeDocument&lt;span class=&quot;hljs-selector-class&quot;&gt;.activeLayer&lt;/span&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.translate&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-attribute&quot;&gt;Height&lt;/span&gt; - Y1);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_7&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7933730580166752187/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/photoshop-move-layer-along-y-axis.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7933730580166752187'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7933730580166752187'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/photoshop-move-layer-along-y-axis.html' title='Photoshop Move Layer Along Y-axis'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-8319864748827892816</id><published>2023-10-06T18:54:00.001-07:00</published><updated>2023-10-06T18:54:37.209-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Angularfire2"/><category scheme="http://www.blogger.com/atom/ns#" term="Firebase"/><category scheme="http://www.blogger.com/atom/ns#" term="Google Cloud Firestore"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Promise"/><title type='text'>How To Handle Promise In Firestore</title><content type='html'>&lt;div class=&quot;question&quot;&gt;here is my code to check a doc is there in the collections this.shopCollection = this.afs.collection&lt;Shop&gt;(&#39;shops&#39;, ref =&gt; {   return ref.where(&#39;fulladdress&#39;, &#39;==&#39;, myStri&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;I got it working with some changes&lt;/p&gt;&lt;p&gt;Here is my code&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;afs&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;collection&lt;/span&gt;&amp;lt;&lt;span class=&quot;hljs-title class_&quot;&gt;Shop&lt;/span&gt;&amp;gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;shops&#39;&lt;/span&gt;).&lt;span class=&quot;hljs-property&quot;&gt;ref&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;where&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;fulladdress&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#39;==&#39;&lt;/span&gt;, myString)
      .&lt;span class=&quot;hljs-title function_&quot;&gt;get&lt;/span&gt;()
      .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;res&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;(res.&lt;span class=&quot;hljs-property&quot;&gt;docs&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt; == &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;){
          &lt;span class=&quot;hljs-comment&quot;&gt;//no documents found&lt;/span&gt;
        }&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;{
          &lt;span class=&quot;hljs-comment&quot;&gt;//you got some documents&lt;/span&gt;
          res.&lt;span class=&quot;hljs-title function_&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;shop&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
            &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(shop.&lt;span class=&quot;hljs-property&quot;&gt;id&lt;/span&gt;);
            &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(shop.&lt;span class=&quot;hljs-title function_&quot;&gt;data&lt;/span&gt;());
          })
        }
      }).&lt;span class=&quot;hljs-title function_&quot;&gt;catch&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;err&lt;/span&gt; =&amp;gt;&lt;/span&gt; {
        &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;something went wrong &#39;&lt;/span&gt;+ err)
      });
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;i am not sure this is the right way, works fine for me.&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/8319864748827892816/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-handle-promise-in-firestore.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8319864748827892816'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8319864748827892816'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-handle-promise-in-firestore.html' title='How To Handle Promise In Firestore'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-9165856875925929729</id><published>2023-10-06T16:34:00.001-07:00</published><updated>2023-10-06T16:34:24.167-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Angularjs"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>App Error Displaying Blank</title><content type='html'>&lt;div class=&quot;question&quot;&gt;my app&#39;s idea is simple. a user inputs text and then it gets diplayed and saved into the db. The problem am having is that it displays blank. I have a lot of code so am going to pu&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;I&#39;m not sure what you mean by &quot;displays blank&quot;, but there is likely an issue with these lines:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-php&quot;&gt;Meetup.query(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;results&lt;/span&gt;) &lt;/span&gt;{
  &lt;span class=&quot;hljs-variable&quot;&gt;$scope&lt;/span&gt;.meetups = results;
});

&lt;span class=&quot;hljs-variable&quot;&gt;$scope&lt;/span&gt;.meetups = []
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;If &lt;code&gt;$scope.meetups&lt;/code&gt; is assigned &lt;code&gt;results&lt;/code&gt;, you may be overwriting that value with &lt;code&gt;$scope.meetups = []&lt;/code&gt;. Remember that the $resource will resolve asynchronously, so assignments won&#39;t exactly happen in the order they are written. Try removing the &lt;code&gt;$scope.meetups = []&lt;/code&gt; line. &lt;/p&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/9165856875925929729/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/app-error-displaying-blank.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/9165856875925929729'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/9165856875925929729'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/app-error-displaying-blank.html' title='App Error Displaying Blank'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7924694231717348769</id><published>2023-10-06T13:40:00.001-07:00</published><updated>2023-10-06T13:40:31.705-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Model View Controller"/><category scheme="http://www.blogger.com/atom/ns#" term="Node.js"/><category scheme="http://www.blogger.com/atom/ns#" term="Sequelize.js"/><title type='text'>Cannot Read Property &#39;sync&#39; Of Undefined</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I am following a tutorial on how to set up a basic mvc in Nodejs using the hapi server and a few other packages. Tutorial: https://www.sitepoint.com/node-js-mvc-application/ Git fo&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;I have got it working by moving my index.js file to the models folder.&lt;/p&gt;&lt;p&gt;This file has the necessairy scripts that dispatches sequelise in the model thus fixing the problem.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Make sure you have exported the db in index.js&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-ini&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;module.exports&lt;/span&gt; = db
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;and declared a db variable at the beginning of the file&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; db = {}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 


</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7924694231717348769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/cannot-read-property-sync-of-undefined.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7924694231717348769'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7924694231717348769'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/cannot-read-property-sync-of-undefined.html' title='Cannot Read Property &#39;sync&#39; Of Undefined'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7551440206405538025</id><published>2023-10-06T12:20:00.001-07:00</published><updated>2023-10-06T12:20:43.219-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Vue Component"/><category scheme="http://www.blogger.com/atom/ns#" term="Vue.js"/><category scheme="http://www.blogger.com/atom/ns#" term="Vuejs2"/><category scheme="http://www.blogger.com/atom/ns#" term="Vuetify.js"/><title type='text'>How To Drop Down Programmatically A Select Menu By Clicking On Image Vuetify?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have my image property and select in template: &lt;v-img src=&#39;/logos/some.jpg&#39;         @click=&#39;click_select&#39;/&gt;&lt;v-select :items=&#39;currencySelect&#39;          ref=&#39;select&#39;/&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Just add a callback handler for that event like :&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;$refs&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;select&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;onClick&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;e&lt;/span&gt;) =&amp;gt;&lt;/span&gt; {

  });
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Full example&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;snippet&quot; data-babel=&quot;false&quot; data-console=&quot;true&quot; data-hide=&quot;false&quot; data-lang=&quot;js&quot;&gt;&lt;div class=&quot;snippet-code&quot;&gt;&lt;pre class=&quot;snippet-code-js lang-js prettyprint-override&quot;&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; app = &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Vue&lt;/span&gt;({
  &lt;span class=&quot;hljs-attr&quot;&gt;el&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;#app&#39;&lt;/span&gt;,
  &lt;span class=&quot;hljs-attr&quot;&gt;vuetify&lt;/span&gt;: &lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Vuetify&lt;/span&gt;(),
  &lt;span class=&quot;hljs-attr&quot;&gt;data&lt;/span&gt;: {
    &lt;span class=&quot;hljs-attr&quot;&gt;currencySelect&lt;/span&gt;: [&lt;span class=&quot;hljs-string&quot;&gt;&#39;a&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#39;b&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#39;c&#39;&lt;/span&gt;]
  },

  &lt;span class=&quot;hljs-attr&quot;&gt;methods&lt;/span&gt;: {
    &lt;span class=&quot;hljs-title function_&quot;&gt;click_select&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {

      &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;$refs&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;select&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;onClick&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;(&lt;span class=&quot;hljs-params&quot;&gt;e&lt;/span&gt;) =&amp;gt;&lt;/span&gt; {

      });
    }
  }
})&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;pre class=&quot;snippet-code-html lang-html prettyprint-override&quot;&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900&quot;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;rel&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css&quot;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;rel&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css&quot;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;rel&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;script&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;app&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;v-app&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;inspire&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;button&lt;/span&gt; @&lt;span class=&quot;hljs-attr&quot;&gt;click&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&#39;click_select&#39;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;v-btn-primary&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;
    select
    &lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;button&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;v-select&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;:items&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;currencySelect&quot;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;ref&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&#39;select&#39;&lt;/span&gt; /&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;v-app&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7551440206405538025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-drop-down-programmatically.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7551440206405538025'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7551440206405538025'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-drop-down-programmatically.html' title='How To Drop Down Programmatically A Select Menu By Clicking On Image Vuetify?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7754149139773411092</id><published>2023-10-06T10:50:00.001-07:00</published><updated>2023-10-06T10:50:15.133-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>How Can I Use Javascript To Get The Highest Value Of Two Variables</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have two variables name var h1 and var h2  each holds some numbers. i want to get highest value to another variable&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Try this to get the maximum:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; result = &lt;span class=&quot;hljs-title class_&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;max&lt;/span&gt;(h1,h2)
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; highestNum = h1 &amp;gt; h2 ? h1: h2;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;or if you dislike tertiary statements:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; highestNum;
&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (h1 &amp;gt; h2) { 
    highestNum = h1;
} &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
    highestNum = h2;
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Edit: Interestingly enough, it appears the if-else statement runs much faster than Math.max (on Chrome 21)&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsperf.com/jbabey-math-max&quot;&gt;http://jsperf.com/jbabey-math-max&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;&lt;s&gt;Fancy way&lt;/s&gt;&lt;strong&gt;The only way it should be done&lt;/strong&gt; :&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; otherVar = &lt;span class=&quot;hljs-title class_&quot;&gt;Math&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;max&lt;/span&gt;(h1,h2);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Long way :&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_4&quot; class=&quot;hljs language-csharp&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; otherVar=&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;;
&lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt;(h1 &amp;gt;= h2)
{
    otherVar = h1;
}
&lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt;
{
    otherVar = h2;
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_4&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Javascript only, no jQuery.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7754149139773411092/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-can-i-use-javascript-to-get-highest.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7754149139773411092'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7754149139773411092'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-can-i-use-javascript-to-get-highest.html' title='How Can I Use Javascript To Get The Highest Value Of Two Variables'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-676477856993096160</id><published>2023-10-06T10:17:00.001-07:00</published><updated>2023-10-06T10:17:43.291-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Asp.net"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Parameters"/><title type='text'>Passing A Serverside Variable To A Javascript Function In Asp.net</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I need to pass a server side variable to my javascript function such as below:   &lt;asp:HyperLink ID=&#39;lnkIDNum&#39; runat=&#39;server&#39; NavigateUrl=&#39;javascript:ChangeLocView(&#39;ChangeView&#39;,&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Got it working like this:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-css&quot;&gt;&amp;lt;asp:HyperLink ID=&lt;span class=&quot;hljs-string&quot;&gt;&quot;lnkIDNum&quot;&lt;/span&gt; 
           runat=&lt;span class=&quot;hljs-string&quot;&gt;&quot;server&quot;&lt;/span&gt; 
           NavigateUrl=&amp;lt;%# &lt;span class=&quot;hljs-string&quot;&gt;&quot;javascript:ChangeLoc(&#39;ChangeView&#39;, &#39;&quot;&lt;/span&gt; + Container.&lt;span class=&quot;hljs-built_in&quot;&gt;DataItem&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;IDNum&quot;&lt;/span&gt;) + &lt;span class=&quot;hljs-string&quot;&gt;&quot;&#39;)&quot;&lt;/span&gt; %&amp;gt;&amp;gt;
     &amp;lt;%#Container.&lt;span class=&quot;hljs-built_in&quot;&gt;DataItem&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&quot;IDNum&quot;&lt;/span&gt;)%&amp;gt;
&amp;lt;/asp:HyperLink&amp;gt;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Try using the Eval() function instead, and do something like this:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-perl&quot;&gt;&amp;lt;asp:HyperLink ID=&lt;span class=&quot;hljs-string&quot;&gt;&quot;lnkEdit&quot;&lt;/span&gt; runat=&lt;span class=&quot;hljs-string&quot;&gt;&quot;server&quot;&lt;/span&gt; NavigateUrl=&lt;span class=&quot;hljs-string&quot;&gt;&quot;someFunc(&#39;ChangeView&#39;, &#39;&amp;lt;%#Eval(&quot;&lt;/span&gt;SomeColumn&lt;span class=&quot;hljs-string&quot;&gt;&quot;)%&amp;gt;&#39;);&quot;&lt;/span&gt;&amp;gt;&amp;lt;%#Eval(&lt;span class=&quot;hljs-string&quot;&gt;&quot;SomeColumn&quot;&lt;/span&gt;)%&amp;gt;&amp;lt;/asp:HyperLink&amp;gt;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_3&quot;&gt;Solution 3:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;You probably should set the attributes in the code behind.&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-vbnet&quot;&gt;&lt;span class=&quot;hljs-type&quot;&gt;string&lt;/span&gt; idNum = Container.DataItem(&lt;span class=&quot;hljs-string&quot;&gt;&quot;IDNum&quot;&lt;/span&gt;);
lnkIDNum.NavigateUrl = 
    &lt;span class=&quot;hljs-string&quot;&gt;&quot;javascript:ChangeLocView (&#39;ChangeView&#39;, &#39;&quot;&lt;/span&gt; 
  + idNum 
  + &lt;span class=&quot;hljs-string&quot;&gt;&quot;&#39;&quot;&lt;/span&gt;;
lnkIDNum.&lt;span class=&quot;hljs-keyword&quot;&gt;Text&lt;/span&gt; = idNum;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;and in the aspx:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;asp:HyperLink&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;ID&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;lnkIDNum&quot;&lt;/span&gt;&lt;span class=&quot;hljs-attr&quot;&gt;runat&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;server&quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;asp:HyperLink&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/676477856993096160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/passing-serverside-variable-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/676477856993096160'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/676477856993096160'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/passing-serverside-variable-to.html' title='Passing A Serverside Variable To A Javascript Function In Asp.net'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-548752736981409216</id><published>2023-10-06T09:45:00.001-07:00</published><updated>2023-10-06T09:45:54.987-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="Jquery Ui"/><title type='text'>How To Get Element Under Mouse Cursor While Dragging Another Element?</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I googled and found several answers but they was all about click or mousemove events which are not suitable for my question. Basically I allow users to drag an item from a list and&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Apparently, the droppable has an hover function. &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jqueryui.com/droppable/#visual-feedback&quot;&gt;http://jqueryui.com/droppable/#visual-feedback&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;$(&lt;span class=&quot;hljs-string&quot;&gt;&quot;#folderlist&quot;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;droppable&lt;/span&gt;({
    &lt;span class=&quot;hljs-attr&quot;&gt;hoverClass&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&quot;ui-state-hover&quot;&lt;/span&gt;,
    &lt;span class=&quot;hljs-attr&quot;&gt;drop&lt;/span&gt;: &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;event, ui&lt;/span&gt;) {
    }
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;Then add this to your css :&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-css&quot;&gt;&lt;span class=&quot;hljs-selector-class&quot;&gt;.ui-state-hover&lt;/span&gt;
{
    &lt;span class=&quot;hljs-attribute&quot;&gt;background-color&lt;/span&gt;: &lt;span class=&quot;hljs-number&quot;&gt;#1c70cf&lt;/span&gt;;
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/548752736981409216/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-get-element-under-mouse-cursor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/548752736981409216'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/548752736981409216'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/how-to-get-element-under-mouse-cursor.html' title='How To Get Element Under Mouse Cursor While Dragging Another Element?'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-3654904615740606985</id><published>2023-10-06T08:24:00.001-07:00</published><updated>2023-10-06T08:24:38.088-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="Json"/><category scheme="http://www.blogger.com/atom/ns#" term="Php"/><title type='text'>Pass Json Object To Array - Autocomplete</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I have two files. location.php, that outputs this:  [[&#39;javascript&#39;],[&#39;PHP&#39;]]   and in another file: &lt;script type=&#39;text/javascript&#39;&gt; $.getJSON(&#39;location.php&#39;, function(data) {&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;$.&lt;span class=&quot;hljs-title function_&quot;&gt;each&lt;/span&gt;(data, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;key, val&lt;/span&gt;) {
  sampleTags.&lt;span class=&quot;hljs-title function_&quot;&gt;push&lt;/span&gt;(val[&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;]);
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;should reduce [[&quot;foo&quot;],[&quot;bar&quot;]] to [&quot;foo&quot;, &quot;bar&quot;]&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-lua&quot;&gt;&lt;span class=&quot;hljs-string&quot;&gt;[[&quot;javascript&quot;], [&quot;PHP&quot;]]&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;is a two dimensional array. Your Javascript is expecting a one dimensional array. Have your PHP output:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-css&quot;&gt;&lt;span class=&quot;hljs-selector-attr&quot;&gt;[ &lt;span class=&quot;hljs-string&quot;&gt;&quot;javascript&quot;&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;PHP&quot;&lt;/span&gt; ]&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;In PHP the array should look like this:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-php&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;array&lt;/span&gt;( &lt;span class=&quot;hljs-string&quot;&gt;&quot;javascript&quot;&lt;/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&quot;php&quot;&lt;/span&gt; );
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 


</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/3654904615740606985/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/pass-json-object-to-array-autocomplete.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/3654904615740606985'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/3654904615740606985'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/pass-json-object-to-array-autocomplete.html' title='Pass Json Object To Array - Autocomplete'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-8867448691038261888</id><published>2023-10-06T04:52:00.001-07:00</published><updated>2023-10-06T04:52:27.667-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Http"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Phantomjs"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Scraping"/><title type='text'>Unable To Load Page Resources With Phantomjs</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I&#39;m using PhantomJS to get page content for given URL. The problem is that on some pages PhantomJS can not load some resources (js, css...), and the error I&#39;m getting is:  error co&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;For coders who come across this page during their quest to find an solution for resources not completely loading on phantomjs. I had a project where the script would stall/hang on a few resources. It was 50/50 if it would execute or not.&lt;/p&gt;&lt;p&gt;Some digging and I found the following page:
&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://github.com/ariya/phantomjs/issues/10652&quot;&gt;https://github.com/ariya/phantomjs/issues/10652&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Where the solution to set an timeout for resources was working out for me:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-ini&quot;&gt;&lt;span class=&quot;hljs-attr&quot;&gt;page.settings.resourceTimeout&lt;/span&gt; = &lt;span class=&quot;hljs-number&quot;&gt;10000&lt;/span&gt;&lt;span class=&quot;hljs-comment&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;In regards to the above question I am not sure if this is completely appropiate but at least the information is easier to find now and can be regarded part of an solution to some.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/8867448691038261888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/unable-to-load-page-resources-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8867448691038261888'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/8867448691038261888'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/unable-to-load-page-resources-with.html' title='Unable To Load Page Resources With Phantomjs'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-7151780670343785354</id><published>2023-10-06T03:18:00.001-07:00</published><updated>2023-10-06T03:18:29.189-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Tracking.js"/><title type='text'>Count Number Of Faces Using Javascript</title><content type='html'>&lt;div class=&quot;question&quot;&gt;Is there a way that I can count the number of faces in a live camera. For example I&#39;ve three persons in front of a webcam and I&#39;m having 2 pages say, Success.html and error .html a&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;From the documentation: &lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-php&quot;&gt;myTracker.on(&lt;span class=&quot;hljs-string&quot;&gt;&#39;track&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;event&lt;/span&gt;) &lt;/span&gt;{
  &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (event.data.length === &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
    &lt;span class=&quot;hljs-comment&quot;&gt;// No targets were detected in this frame.&lt;/span&gt;
  } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
    event.data.&lt;span class=&quot;hljs-keyword&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;data&lt;/span&gt;) &lt;/span&gt;{
      &lt;span class=&quot;hljs-comment&quot;&gt;// Plots the detected targets here.&lt;/span&gt;
    });
  }
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;p&gt;It seems to be &lt;code&gt;event.data.length&lt;/code&gt; that gives you the number of tracked elements.&lt;/p&gt;&lt;/div&gt;&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Fom the docs at &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://trackingjs.com/docs.html#trackers&quot;&gt;https://trackingjs.com/docs.html#trackers&lt;/a&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;code id=&quot;code_2&quot; class=&quot;hljs language-php&quot;&gt;myTracker.on(&lt;span class=&quot;hljs-string&quot;&gt;&#39;track&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;event&lt;/span&gt;) &lt;/span&gt;{
  &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (event.data.length === &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;) {
    &lt;span class=&quot;hljs-comment&quot;&gt;// No targets were detected in this frame.&lt;/span&gt;
  } &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
    event.data.&lt;span class=&quot;hljs-keyword&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;data&lt;/span&gt;) &lt;/span&gt;{
      &lt;span class=&quot;hljs-comment&quot;&gt;// Plots the detected targets here.&lt;/span&gt;
    });
  }
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_2&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;p&gt;Use &lt;code&gt;event.data.length&lt;/code&gt; to count the amount of faces.&lt;/p&gt;&lt;p&gt;On your piece of code :&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_4&quot; class=&quot;hljs language-javascript&quot;&gt;tracker.&lt;span class=&quot;hljs-title function_&quot;&gt;on&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;track&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;event&lt;/span&gt;) {
    context.&lt;span class=&quot;hljs-title function_&quot;&gt;clearRect&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, canvas.&lt;span class=&quot;hljs-property&quot;&gt;width&lt;/span&gt;, canvas.&lt;span class=&quot;hljs-property&quot;&gt;height&lt;/span&gt;);
    &lt;span class=&quot;hljs-comment&quot;&gt;// console log amount of elements found&lt;/span&gt;&lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(event.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt;);
    event.&lt;span class=&quot;hljs-property&quot;&gt;data&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;forEach&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;rect&lt;/span&gt;) {
        &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;log&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;face detected&#39;&lt;/span&gt;);
    });
});
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_4&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 


</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/7151780670343785354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/count-number-of-faces-using-javascript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7151780670343785354'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/7151780670343785354'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/count-number-of-faces-using-javascript.html' title='Count Number Of Faces Using Javascript'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-6553076096422234724</id><published>2023-10-06T02:32:00.001-07:00</published><updated>2023-10-06T02:32:44.741-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="React Redux"/><category scheme="http://www.blogger.com/atom/ns#" term="Reactjs"/><title type='text'>Script Load In React</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I want to load the script from a CDN and then execute a function exposed by that script in React: componentWillMount() {     console.log(&#39;componentWillMount is called&#39;);     const&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;I don&#39;t think it&#39;s a good idea to load scripts in componentWillMount() or componentDidMount(), according to &lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;http://reactjs.cn/react/docs/component-specs.html&quot;&gt;React Component Specs and Lifecycle&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;The code below may help you.&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;hljs-title function_&quot;&gt;new_script&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;src&lt;/span&gt;) {
  &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;Promise&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;resolve, reject&lt;/span&gt;){
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; script = &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;createElement&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;script&#39;&lt;/span&gt;);
    script.&lt;span class=&quot;hljs-property&quot;&gt;src&lt;/span&gt; = src;
    script.&lt;span class=&quot;hljs-title function_&quot;&gt;addEventListener&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;load&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
      &lt;span class=&quot;hljs-title function_&quot;&gt;resolve&lt;/span&gt;();
    });
    script.&lt;span class=&quot;hljs-title function_&quot;&gt;addEventListener&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;error&#39;&lt;/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;e&lt;/span&gt;) {
      &lt;span class=&quot;hljs-title function_&quot;&gt;reject&lt;/span&gt;(e);
    });
    &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;body&lt;/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;appendChild&lt;/span&gt;(script);
  })
};
&lt;span class=&quot;hljs-comment&quot;&gt;// Promise Interface can ensure load the script only once.&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; my_script = &lt;span class=&quot;hljs-title function_&quot;&gt;new_script&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;http://example.com/aaa.js&#39;&lt;/span&gt;);

&lt;span class=&quot;hljs-keyword&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hljs-title class_&quot;&gt;App&lt;/span&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;extends&lt;/span&gt;&lt;span class=&quot;hljs-title class_ inherited__&quot;&gt;React.Component&lt;/span&gt; {

  &lt;span class=&quot;hljs-title function_&quot;&gt;constructor&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;props&lt;/span&gt;) {
    &lt;span class=&quot;hljs-variable language_&quot;&gt;super&lt;/span&gt;(props);
    &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;state&lt;/span&gt; = {
      &lt;span class=&quot;hljs-attr&quot;&gt;status&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;start&#39;&lt;/span&gt;
    };
  }

  do_load = &lt;span class=&quot;hljs-function&quot;&gt;() =&amp;gt;&lt;/span&gt; {
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; self = &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;;
    my_script.&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
      self.&lt;span class=&quot;hljs-title function_&quot;&gt;setState&lt;/span&gt;({&lt;span class=&quot;hljs-string&quot;&gt;&#39;status&#39;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;done&#39;&lt;/span&gt;});
    }).&lt;span class=&quot;hljs-title function_&quot;&gt;catch&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
      self.&lt;span class=&quot;hljs-title function_&quot;&gt;setState&lt;/span&gt;({&lt;span class=&quot;hljs-string&quot;&gt;&#39;status&#39;&lt;/span&gt;: &lt;span class=&quot;hljs-string&quot;&gt;&#39;error&#39;&lt;/span&gt;});
    })
  }

  &lt;span class=&quot;hljs-title function_&quot;&gt;render&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; self = &lt;span class=&quot;hljs-variable language_&quot;&gt;this&lt;/span&gt;;
    &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (self.&lt;span class=&quot;hljs-property&quot;&gt;state&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;status&lt;/span&gt; === &lt;span class=&quot;hljs-string&quot;&gt;&#39;start&#39;&lt;/span&gt;) {
      self.&lt;span class=&quot;hljs-property&quot;&gt;state&lt;/span&gt;.&lt;span class=&quot;hljs-property&quot;&gt;status&lt;/span&gt; = &lt;span class=&quot;hljs-string&quot;&gt;&#39;loading&#39;&lt;/span&gt;;
      &lt;span class=&quot;hljs-built_in&quot;&gt;setTimeout&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;&lt;/span&gt;) {
        self.&lt;span class=&quot;hljs-title function_&quot;&gt;do_load&lt;/span&gt;()
      }, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
    }

    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; (
      &lt;span class=&quot;language-xml&quot;&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;{self.state.status}   {self.state.status === &#39;done&#39; &amp;amp;&amp;amp; &#39;here you can use the script loaded&#39;}&lt;span class=&quot;hljs-tag&quot;&gt;&amp;lt;/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    );
  }
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/6553076096422234724/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/script-load-in-react.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6553076096422234724'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/6553076096422234724'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/script-load-in-react.html' title='Script Load In React'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-61656277704938057</id><published>2023-10-06T00:12:00.001-07:00</published><updated>2023-10-06T00:12:26.930-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Arrays"/><category scheme="http://www.blogger.com/atom/ns#" term="Combinations"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="Recursion"/><title type='text'>Using Recursion To Search All Combinations Of Elements In An Array Of Integers</title><content type='html'>&lt;div class=&quot;question&quot;&gt;I am working on this problem from Coderbyte using JS: Have the function ArrayAdditionI(arr) take the array of numbers stored in arr and return the string true if any combination of&lt;/div&gt;

&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;
&lt;div class=&quot;answer-desc&quot;&gt;&lt;p&gt;Your algorithm has a flaw. Your function looks only one step forward.
You need to add loop inside to look over all rest values.&lt;/p&gt;
&lt;pre&gt;&lt;code id=&quot;code_0&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;ArrayAdditionI&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;arr&lt;/span&gt;) {
    &lt;span class=&quot;hljs-comment&quot;&gt;// sorting the array to easily remove the biggest value&lt;/span&gt;
    &lt;span class=&quot;hljs-comment&quot;&gt;// slice added to prevent original array modification&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; sArr = arr.&lt;span class=&quot;hljs-title function_&quot;&gt;slice&lt;/span&gt;().&lt;span class=&quot;hljs-title function_&quot;&gt;sort&lt;/span&gt;(&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; (&lt;span class=&quot;hljs-params&quot;&gt;a, b&lt;/span&gt;) { 
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; a - b;
    });
    &lt;span class=&quot;hljs-comment&quot;&gt;// removing the biggest value&lt;/span&gt;
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; biggest = sArr.&lt;span class=&quot;hljs-title function_&quot;&gt;pop&lt;/span&gt;();
    &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;recursion&lt;/span&gt;(&lt;span class=&quot;hljs-params&quot;&gt;start, i&lt;/span&gt;) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; result = &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
        &lt;span class=&quot;hljs-comment&quot;&gt;// looking over all rest values of array&lt;/span&gt;
        &lt;span class=&quot;hljs-keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; j = i; j &amp;lt; sArr.&lt;span class=&quot;hljs-property&quot;&gt;length&lt;/span&gt; &amp;amp;&amp;amp; !result; j++) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (sArr[j] + start === biggest) {
                result = &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
            }
            &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start + sArr[j] &amp;lt; biggest) {
                result = &lt;span class=&quot;hljs-title function_&quot;&gt;recursion&lt;/span&gt;(start + sArr[j], j + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;);
            }
        }
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; result;
    }
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-title function_&quot;&gt;recursion&lt;/span&gt;(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_0&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 
&lt;br&gt;
&lt;h2 id=&quot;solution_2&quot;&gt;Solution 2:

&lt;/h2&gt;
&lt;div class=&quot;answer-desc&quot;&gt;&lt;pre&gt;&lt;code id=&quot;code_1&quot; class=&quot;hljs language-kotlin&quot;&gt;function ArrayAdditionI (arr) {
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; sArr = arr.sort(function (a,b) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; a-b;
    });
    &lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; biggest = sArr.pop();
    function recursion (start, indx) {
        &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start + sArr[indx] === biggest) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;/span&gt;;
        }
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (sArr.length &amp;lt; indx) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
        }
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;hljs-keyword&quot;&gt;if&lt;/span&gt; (start + sArr[indx] &amp;lt; biggest) {
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; recursion(start + sArr[indx], indx + &lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;) || recursion(start, indx+&lt;span class=&quot;hljs-number&quot;&gt;1&lt;/span&gt;)
        }
        &lt;span class=&quot;hljs-keyword&quot;&gt;else&lt;/span&gt; {
            &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;hljs-literal&quot;&gt;false&lt;/span&gt;;
        }
    }
    &lt;span class=&quot;hljs-keyword&quot;&gt;return&lt;/span&gt; recursion(&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;hljs-number&quot;&gt;0&lt;/span&gt;);
}
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_1&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/div&gt; 

&lt;br&gt;
</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/61656277704938057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/using-recursion-to-search-all.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/61656277704938057'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/61656277704938057'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/using-recursion-to-search-all.html' title='Using Recursion To Search All Combinations Of Elements In An Array Of Integers'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2769472574235259169.post-2813032363754630186</id><published>2023-10-05T23:24:00.001-07:00</published><updated>2023-10-05T23:24:31.772-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Html"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><title type='text'>Printing Array Into Table Through Javascript</title><content type='html'>&lt;div class=&quot;question&quot;&gt;Currently when you add some values in the 4 textboxes identified by &#39;Special&#39; it outputs in a concatenated string. How would I break that up into a table where I could print it out&lt;/div&gt;&lt;h2 id=&quot;solution_1&quot;&gt;Solution 1:

&lt;/h2&gt;&lt;div class=&quot;answer-desc&quot;&gt;&lt;h3&gt;Full solution on JSFiddle:&lt;/h3&gt;&lt;p&gt;&lt;a rel=&quot;nofollow noreferrer noopener&quot; href=&quot;https://jsfiddle.net/protron/xGhnv/9/&quot;&gt;http://jsfiddle.net/protron/xGhnv/9/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Basically what I did was:&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;p&gt;In the HTML I replaced the &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; called &lt;code&gt;list&lt;/code&gt; for a new &lt;code&gt;&amp;lt;table&amp;gt;&lt;/code&gt;:&lt;/p&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;pre&gt;&lt;code id=&quot;code_3&quot; class=&quot;hljs language-bash&quot;&gt;&amp;lt;table &lt;span class=&quot;hljs-built_in&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;tableDailyDeals&quot;&lt;/span&gt;&amp;gt;&amp;lt;/table&amp;gt;
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_3&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;In the Javascript instead of calling &lt;code&gt;$(elem).text(...&lt;/code&gt; I create a new table row (&lt;code&gt;&amp;lt;tr&amp;gt;&lt;/code&gt;) in the table just defined:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_6&quot; class=&quot;hljs language-javascript&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt; $tr = $(&lt;span class=&quot;hljs-string&quot;&gt;&#39;&amp;lt;tr&amp;gt;&#39;&lt;/span&gt;).&lt;span class=&quot;hljs-title function_&quot;&gt;appendTo&lt;/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#39;#tableDailyDeals&#39;&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_6&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Then besides adding the &lt;code&gt;input-hidden&lt;/code&gt; for each dailyDeal attribute (for 0 to 3) I also create a table cell (&lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt;) and inside it a new &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; with the text you already have in your array named &lt;code&gt;dailyDeal&lt;/code&gt; (the span is optional, but as I also put the input-hidden in the same td I think is better this way):&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_11&quot; class=&quot;hljs language-ruby&quot;&gt;var &lt;span class=&quot;hljs-variable&quot;&gt;$td&lt;/span&gt; = &lt;span class=&quot;hljs-variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&#39;&amp;lt;td&amp;gt;&#39;&lt;/span&gt;).appendTo(&lt;span class=&quot;hljs-variable&quot;&gt;$tr&lt;/span&gt;);
&lt;span class=&quot;hljs-variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;&#39;&amp;lt;span&amp;gt;&#39;&lt;/span&gt;).text(dailyDeal[i]).appendTo(&lt;span class=&quot;hljs-variable&quot;&gt;$td&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_11&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Then just add another table cell (&lt;code&gt;&amp;lt;td&amp;gt;&lt;/code&gt;) for the row remover link:&lt;/p&gt;&lt;pre&gt;&lt;code id=&quot;code_13&quot; class=&quot;hljs language-php&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;var&lt;/span&gt;&lt;span class=&quot;hljs-variable&quot;&gt;$tdRemoveRow&lt;/span&gt; = $(&lt;span class=&quot;hljs-string&quot;&gt;&#39;&amp;lt;td&amp;gt;&#39;&lt;/span&gt;).appendTo(&lt;span class=&quot;hljs-variable&quot;&gt;$tr&lt;/span&gt;);
&lt;/code&gt;&lt;button class=&quot;copy-btn btn btn-secondary btn-sm&quot; onclick=&quot;copyCode(this,&#39;code_13&#39;)&quot;&gt;Copy&lt;/button&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;The rest is just some css styling and minor details.&lt;/p&gt;&lt;/div&gt; 

</content><link rel='replies' type='application/atom+xml' href='https://pracasify.blogspot.com/feeds/2813032363754630186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='https://pracasify.blogspot.com/2023/10/printing-array-into-table-through.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/2813032363754630186'/><link rel='self' type='application/atom+xml' href='https://www.blogger.com/feeds/2769472574235259169/posts/default/2813032363754630186'/><link rel='alternate' type='text/html' href='https://pracasify.blogspot.com/2023/10/printing-array-into-table-through.html' title='Printing Array Into Table Through Javascript'/><author><name>Mrs. Leticia Nikolaus</name><uri>http://www.blogger.com/profile/00757516236571157375</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>