lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I am using some very simple html5 and js code to take photo by click of a button from mobile browser and send it to web service . This part of code works perfectly in Safari in Ios ( Ipad ) . Also code works perfectly in Chrome browser Desktop and Desktop Mobile mode.In Chrome browser on Ios ; The part I take photo wor... | < tr id= '' photo-functions-row '' > < td > < /td > < td > < div style= '' max-width:30 % '' > < label for= '' take-photo '' class= '' custom-file-upload '' > < i class= '' fa fa-cloud-upload '' > < /i > Take Photo < /label > < input type= '' file '' accept= '' image/* '' capture= '' camera '' id= '' take-photo '' onch... | Some part of javascript code make chrome hang in Ios |
JS | I want to test whether an object is empty : { } . The following is typically used : But suppose the Object prototype was added to as follows : Tests : I tried to nuke the object 's prototype , change it 's constructor , and all manner of such hacks . Nothing worked , but maybe I did it wrong ( probable ) . | function isEmpty ( obj ) { for ( var prop in obj ) { if ( obj.hasOwnProperty ( prop ) ) return false ; } return true ; } Object.prototype.Foo = `` bar '' ; alert ( isEmpty ( { } ) ) ; // trueObject.prototype.Foo = `` bar '' ; alert ( { } .Foo ) ; // `` bar '' oh no ... alert ( isEmpty ( { } ) ) ; // true ... **huh ? ! ... | How to test whether object `` isEmpty ( ) '' if Object.prototype was modified ? |
JS | While investigating google plusone scripts , I 've seen following syntax many times : Assuming _.Em is a function the statement above would result in calling that function , that 's pretty obvious . If , on the other hand , it would be undefined , would n't the result be the same as doing simply _.Em ( ) ? Can anyone s... | ( 0 , _.Em ) ( ) ; | What 's the reason for using such syntax ( 0 , _.Em ) ( ) ; |
JS | I have here a button with an onload script.HTMLSCRIPTUpon selection , I can see all the filetypes . What I want is to see image file types only automatically like using input file with accept attribute . | < button class= '' btn default-btn logo_btn '' id= '' photo_uploader '' > Upload New Photo < /button > $ ( function ( ) { var btnUpload= $ ( ' # photo_uploader ' ) ; new AjaxUpload ( btnUpload , { action : base_URL+'upload ' , data : { pid : $ ( ' # page ' ) .data ( 'id ' ) } , dataType : 'json ' , name : 'fileToUpload... | new AjaxUpload accept only image from button tag |
JS | I 'm creating a custom Alexa skill and it need to collect a unknown number of names that the user says.I have tried to store the names in a slot . I was able to get one name to work this way but not multiple . Right now , I am trying to ask the user for a number of people and then ask the user the names . But , I can n... | // Api call wrapped into a promise . Returns the person 's email . return findEmployee ( sessionAttributes.client , givenName ) .then ( attendee = > { let prompt = `` if ( attendee.value.length === 1 ) { sessionAttributes.attendees = [ ... sessionAttributes.attendees , attendee.value [ 0 ] ] prompt = ` $ { attendee.val... | How would I ask the user for a list of names ? |
JS | I am currently reading the Mostly Adequate Guide on functional programming , chapter 2.There , the following example is givenwhich is then refactored into : While explaining the refactoring , the author argues thatis the same asWhile I understand that ajaxCall is called with the return value of the anonymous function (... | var getServerStuff = function ( callback ) { return ajaxCall ( function ( json ) { return callback ( json ) ; } ) ; } ; var getServerStuff = ajaxCall ; return ajaxCall ( function ( json ) { return callback ( json ) ; } ) ; return ajaxCall ( callback ) ; | Where did the argument go in this example ? |
JS | I have a list of 20 phrases that I want to count in an article.Currently , I 'm doingThis requires me to do an expensive search each time . Is there some way to do it faster or all at once ? | let counts = phrases.map ( ( phrase , idx ) = > { phrase.usage = ( articleBody.match ( new RegExp ( phrase.phrase , 'gi ' ) ) || [ ] ) .length return phrase } ) | How can I count the number of times different terms occur in a string string with JavaScript ? |
JS | I was reading through this : https : //github.com/pburtchaell/redux-promise-middleware/blob/master/src/index.jsI know that ... is being used as Object spread . I know that ! ! is used to convert anything into a boolean with the same truthiness.However knowing this what do they mean when they 're put together like ... !... | { ... resolveAction , ... isAction ( rejected ) ? rejected : { ... ! ! rejected & & { payload : rejected } } | What is ... ! ! syntax in ES6 ? |
JS | I am currently working a plugin with a settings variable that is fairly deep ( 3-4 levels in some places ) . Following the generally accepted jQuery Plugin pattern I have implemented a simple way for users to modify settings on the fly using the following notation : Here is the code similar to what I am using now for t... | $ ( ' # element ' ) .plugin ( 'option ' , 'option_name ' , 'new_value ' ) ; option : function ( option , value ) { if ( typeof ( option ) === 'string ' ) { if ( value === undefined ) return settings [ option ] ; if ( typeof ( value ) === 'object ' ) $ .extend ( true , settings [ option ] , value ) ; else settings [ opt... | jQuery Plugin - Deep option modification |
JS | Is it possible , in Javascript , to prompt user for downloading a file that is n't actually on the server , but has contents of a script variable , instead ? Something in spirit with : Cheers , MH | var contents = `` Foo bar '' ; invoke_download_dialog ( contents , `` text/plain '' ) ; | Downloading a variable |
JS | I 'm looking for an easy way to locate elements on the page that have margin-left and margin-right set to auto.I got this script , that helps me some of the time : While this function gets some of the job done , it does n't catch most cases of margin : auto I 've seen in websites.Can you show me a better way ? | ( function ( ) { var elementsList = [ ] ; for ( var i = 0 ; i < document.styleSheets.length ; i++ ) { var styleSheet = document.styleSheets [ i ] ; if ( styleSheet.rules ) { for ( var j = 0 ; j < styleSheet.rules.length ; j++ ) { var rule = styleSheet.rules [ j ] ; if ( rule & & rule.style & & rule.style.marginLeft == ... | Javascript way to locate all elements with margin : auto |
JS | quick summaryI 'm trying to create a button that has both a regular click and a separate action that happens when a user clicks and holds it , similar to the back button in Chrome.The way I 'm doing this involves a setTimeout ( ) with a callback that checks for something in state . For some reason , the callback is usi... | const Button = ( { clickHandler , clickHoldHandler , children } ) = > { const [ isHolding , setIsHolding ] = useState ( false ) ; const [ holdStartTime , setHoldStartTime ] = useState ( undefined ) ; const holdTime = 1000 ; const clickHoldAction = e = > { console.log ( ` is holding : $ { isHolding } ` ) ; if ( isHoldin... | Function called in setTimeout not using current React state |
JS | Given the following : How come this works as a pointfree implementation of average ? I do n't understand why I can pass R.sum and R.length when they are functions and therefore , I can not map the lifted R.divide over the functions R.sum and R.length unlike in the following example : In the above case the values in xs ... | var average = R.lift ( R.divide ) ( R.sum , R.length ) var sum3 = R.curry ( function ( a , b , c ) { return a + b + c ; } ) ; R.lift ( sum3 ) ( xs ) ( ys ) ( zs ) R.ap ( R.ap ( R.ap ( [ tern ] , [ 1 , 2 , 3 ] ) , [ 2 , 4 , 6 ] ) , [ 3 , 6 , 8 ] ) R.lift ( tern ) ( [ 1 , 2 , 3 ] , [ 2 , 4 , 6 ] , [ 3 , 6 , 8 ] ) | How come I can pass functions to a lifted R.divide ? |
JS | Edit : As Andrew Moore pointed out this question is a duplicate of Two separate script tags for Google Analytics ? So this question should be deleted to avoid cluttering Stack Overflow , unless there is a point in keeping this one , since it will probably show up in slightly different searches.What difference does it m... | < script type= '' text/javascript '' > var gaJsHost = ( ( `` https : '' == document.location.protocol ) ? `` https : //ssl . '' : `` http : //www . `` ) ; document.write ( unescape ( `` % 3Cscript src= ' '' + gaJsHost + `` google-analytics.com/ga.js ' type='text/javascript ' % 3E % 3C/script % 3E '' ) ) ; < /script > <... | What difference does it make to use several script blocks on a web page ? |
JS | The one question I have is why the second time I call x.modifyPrivate ( true ) why is it that when line X is run , the value of _private passed in is still 'false ' . I can make sense of this if I modify my knowledge of closures slightly to be that the closure is done by reference , and when you change the value of a r... | function modify ( val , newVal ) { val = newVal ; } constructorFunc = function ( ) { var _private = false ; return { modifyPrivate : function ( toVal ) { return modify ( _private , toVal ) ; // LINE REFERRED TO BELOW AS X } } ; } var x = constructorFunc ( ) ; x.modifyPrivate ( true ) ; x.modifyPrivate ( true ) ; // _pr... | Private members in module pattern , not mutable ? |
JS | Is it possible to call a method from an object using a string ? | var elem = $ ( ' # test ' ) ; // < div id= '' test '' > < /div > var str = `` attr ( 'id ' ) '' ; //This is what I 'm trying to achieve elem.attr ( 'id ' ) ; //test//What I 've tried so far elem.str ; //undefined elem.str ( ) ; //Object [ object Object ] has no method 'str ' var fn = eval ( str ) ; //attr is not define... | Is it possible to call a method from an object using a string ? |
JS | I am setting up a new website and need my text to change colour based on the ever-changing background colours in order to maintain contrast . I have scoured the web for answers that do n't involve Sass , but none have worked ... I have tried some JavaScript , but they work only when the background is a fixed colour tha... | var color = function getRandomColor ( ) { var letters = '0123456789ABCDEF'.split ( `` ) ; var color = ' # ' ; for ( var i = 0 ; i < 6 ; i++ ) { color += letters [ Math.floor ( Math.random ( ) * 16 ) ] ; } return color ; } setInterval ( function ( ) { document.getElementById ( `` test '' ) .style.backgroundColor = color... | How to dynamically change text colour based on dynamically changing background colour |
JS | I 'm using a map plugin to render some data . The data comes from the DB and into a json file - the script works great . I decided to use the data directly from the php output instead of making a json file . For some reason the javaScript does n't accept the direct php input . I 'm using codeigniter MVCHere is the samp... | $ .getJSON ( '_data/index/data.json ' , function ( data ) { ... var dataMap = ' < ? print $ mapData ; ? > ' ; $ .getJSON ( dataMap , function ( data ) { ... var dataMap = ' < ? php echo $ mapData ; ? > ' ; $ .get ( dataMap , function ( data ) { ... { `` countries '' : { `` AL '' : '' 1 '' , '' GB '' : '' 1 '' , '' RS '... | How to use JSON from db/php in JavaScript |
JS | I have two types of elements , let 's call them .a and .b.They may have some CSS animations set on them . I do n't have control over these keyframes , over whether they 're set or not , over what they 're animating.They may be animating opacity . However , I want the opacity on my .a elements to stay a certain value , ... | div { /* some dummy styles so we can see stuff */ display : inline-block ; width : 5em ; height : 5em ; background : purple ; } [ class*='ani ' ] { animation : a 1s ease-out infinite alternate } .ani -- one { animation-name : ani-one } @ keyframes ani-one { to { transform : scale ( .5 ) } } .ani -- two { animation-name... | Force a property of an element to a certain value even as it 's being animated |
JS | I pass 2 arrays to a function and want to move a specific entry from one array to another . The moveDatum function itself uses underscorejs ' methods reject and filter . My Problem is , the original arrays are not changed , as if I was passing the arrays as value and not as reference . The specific entry is correctly m... | this.moveDatum ( sourceArr , targetArr , id ) function moveDatum ( srcDS , trgDS , id ) { var ds = _ ( srcDS ) .filter ( function ( el ) { return el.uid === uid ; } ) ; srcDS = _ ( srcDS ) .reject ( function ( el ) { return el.uid === uid ; } ) ; trgDS.push ( ds [ 0 ] ) ; return this ; } | change array passed to function |
JS | Implementing a JQuery progress bar so when you scroll down it should show a green bar across the top . When I start scrolling the progress bar does not appear . I inspect element on the bar the element it shows the width % going up see screenshot scroll.jsshow.html.erblooking at the logs its not finding scroll but its ... | $ ( document ) .on ( 'scroll ' , function ( ) { var pixelsFromTop = $ ( document ) .scrollTop ( ) var documentHeight = $ ( document ) .height ( ) var windowHeight = $ ( window ) .height ( ) var difference = documentHeight - windowHeight var percentage = 100 * pixelsFromTop / difference $ ( '.bar ' ) .css ( 'width ' , p... | Rails5 + JQuery progress bar not functioning |
JS | I am trying to create an Object with the name and user id for each service , I want the object to look like this : I have tried changing the object property in the map return but it 's not working , also I already have the object half done I mean with the names of the providers now I need the other key , value pairThis... | const object = { name : Netflix , user : ( user id who pays max price for this provider ) name : Comcast , user : ( same ) name : Verizon , user : ( same ) } const services = [ { userid : 1 , providerId : 1 , amount : 250000 } , { userid : 4 , providerId : 3 , amount : 280900 } , { userid : 6 , providerId : 3 , amount ... | How to get users id after filter and map |
JS | I have a leaflet map with circle markers and a radial bar chart . I would like : the circle markers to move with the underlying map ( so that they remaintrue to their real world position ) butthe radial chart to remain constant within the window / containerwhen the map is movedThe circle markers move fine , but the rad... | < ! DOCTYPE html > < html > < head > < meta charset= '' utf-8 '' > < link rel= '' stylesheet '' href= '' https : //d19vzq90twjlae.cloudfront.net/leaflet-0.7/leaflet.css '' / > < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js '' > < /script > < ! -- Load d3.js -- > < script src= '' https : /... | Leaflet overlaid with D3 Chart - Need chart to remain in one place |
JS | I 'm new to Angular and I was reading over the filter documentation and I saw this code . I 'm unclear on what the ng-model= '' search. $ '' means . The two way binding with ng-model is clear , but what about the `` search. $ '' ? What is that doing and how does it work with the filter . I tried searching for this and ... | < label > Any : < input ng-model= '' search. $ '' > < /label > < br > < label > Name only < input ng-model= '' search.name '' > < /label > < br > < label > Phone only < input ng-model= '' search.phone '' > < /label > < br > < tr ng-repeat= '' friendObj in friends | filter : search : strict '' > | Ng-Model= '' something. $ '' what does this mean ? |
JS | I made a basic application in Meteor , and used velocity with mocha . I tried to find ways to build on travis ci . Travis suggested using the following for a .travis.ymlUnfortunately , this seems to be based on the deprecated laika framework.Is there any way to use the velocity framework on a meteor app and have it bui... | language : node_jsnode_js : - `` 0.10 '' before_install : - `` curl -L http : //git.io/3l-rRA | /bin/sh '' services : - mongodbenv : - LAIKA_OPTIONS= '' -t 5000 '' | use velocity , meteor , and travis ci |
JS | I 'm wanting to match any instance of text in a comma-delimited list . For this , the following regular expression works great : ( Regex101 demo ) .The problem is that I 'm wanting to ignore any commas which are contained within either single or double quotes and I 'm unsure how to extend the above selector to allow me... | / [ ^ , ] +/g abcd , efgh , ij '' k , l '' , mnop , ' q , rs't abcd , efgh , ij '' k , l '' , mnop , ' q , rs't ^ ^ ^ ^ | Matching items in a comma-delimited list which are n't surrounded by single or double quotes |
JS | I have an array of objects i want to filter only the unique style and is not repeated . | const arrayOfObj = [ { name : ' a ' , style : ' p ' } , { name : ' b ' , style : ' q ' } , { name : ' c ' , style : ' q ' } ] result expected : [ { name : ' a ' , style : ' p ' } ] | Filter only unique values from an array of object javascript |
JS | I 'm using jqPlot to generate a stacked bar chart based on data from a web method . The chart renders successfully , but is blank . When I set the pointLabels to 'true ' , they appear in a jumble to the left of the chart . I 'm guessing the stacked bars are also being rendered off-chart , but I do n't understand why.Co... | [ WebMethod ] [ ScriptMethod ( ResponseFormat = ResponseFormat.Json ) ] public List < dataPoint > getPartnerOrderVolumes ( ) { List < dataPoint > p = new List < dataPoint > ( ) ; DataTable dt = new DataTable ( ) ; chart jep = new chart ( 5 ) ; foreach ( chartData cd in jep.lstChartData ) { dt = cd.GetData ( ) ; } if ( ... | jqPlot Stacked Bar Chart rendered off-chart |
JS | I am using codepress in a CMS to edit files in the filesystem . Everything works nicely , however when trying to load the same page using jQuery load ( ) function , codepress seems to break.My javascript code looks like this which loads the php file with codpress , however codepress seems to not fire.Digging into codep... | $ ( '.content ' ) .on ( 'click ' , ' # fileSystemWrap a ' , function ( event ) { event.preventDefault ( ) ; var fileName = $ ( this ) .data ( 'file ' ) ; $ ( ' # rightColWrap ' ) .fadeOut ( 150 , function ( ) { $ ( ' # rightColWrap ' ) .load ( '/ ? url=developer/edit-file.php & open= ' + fileName , function ( ) { $ ( '... | How to use jQuery to load codepress |
JS | I am in the midst of creating an online contact management tool for users to manage contacts and clients . I am trying to develop a solution where the user will add a BCC or CC in any email client like this : and my app will grab the recipients to address information email , name , etc and my backend script will grab t... | 1234 @ myappdomain.12345.com | create an email drop box with php , javascript etc |
JS | I was reading on javascript garden http : //bonsaiden.github.com/JavaScript-Garden/ about prototype in javascript and one of its example goes like this : Notice the line that reads Make sure to list Bar as the actual constructor . I really am lost about what this does/is . I have tried making new instances of Bar ( ) w... | function Foo ( ) { this.value = 42 ; } Foo.prototype = { method : function ( ) { } } ; function Bar ( ) { } // Set Bar 's prototype to a new instance of FooBar.prototype = new Foo ( ) ; Bar.prototype.foo = 'Hello World ' ; // Make sure to list Bar as the actual constructor < -- -- -- -- -- -- -- -- -- -Bar.prototype.co... | why does listing the actual constructor of a class in javascript important |
JS | I was studying the concept of variable scope in JS , found this example on it : output of this function isNow I am confused how come foo gets gets value 3 in second log . even when foo is declared by using var in if statement . should n't the foo declared in if will have a new instance as it gets in bar ( ) ? ? | ( function ( ) { var foo = 1 ; function bar ( ) { var foo = 2 ; } bar ( ) ; console.log ( foo ) //outputs 1 if ( true ) { var foo = 3 ; } console.log ( foo ) //outputs 3 } ) ( ) ; 1 3 | variables scope confusion in javascript |
JS | I have function that is going to display message containing product name . But problem appeared when Item contained ' inside . Can this be prevented to take whole string as it is and ignore ' characterCalling functionNOT WORKING FOR - > Razer Blade 15'javascript | cart.add ( ' < ? php echo ( $ imeProizvoda ) ; ? > ' ) var cart = { 'add ' : function ( product_id ) { addProductNotice ( 'Proizvod dodat u korpu ' , ' < h3 > '+product_id+ ' dodat u < a href= '' cart.php '' > korpu < /a > ! < /h3 > ' , 'success ' ) ; } } | How to allow string to contain ' in javascript function |
JS | I 'm really puzzled with Javascript this time : What on earth is going on here ? If it helps , I also noticed : x ( [ 1,2 ] , [ 3,4 ] ) does not work eithertoString also thinks it 's a function : This also happens with Array.prototype.concat.apply.When it is forced as an expression it also does not work : Tested in Chr... | var x = Array.prototype.concat.call ; typeof x ; // functionx ( ) ; // Uncaught TypeError : x is not a function Object.prototype.toString.call ( x ) ; // `` [ object Function ] '' ( 0 , Array.prototype.concat.call ) ( [ 1,2 ] , [ 3,4 ] ) ; // Same TypeError | Javascript : typeof says `` function '' but it ca n't be called as a function |
JS | Hi everyone i have one problem with ajax hover . I am trying to make a userHoverCard like tumblr . But the hover animation not working when i use it with ajax.This is working DEMO without ajax only css . In this demo you can see when you hover image then .p-tooltip will open with animation effect . But if you click thi... | < div class= '' p-tooltip '' > < /div > < div class= '' summary '' data-id= '' 25 '' > < a href= # '' class= '' profile-ava '' > < /a > < /div > < div class= '' summary '' data-id= '' 20 '' > < a href= # '' class= '' profile-ava '' > < /a > < /div > < div class= '' summary '' data-id= '' 25 '' > < a href= # '' class= '... | Tumblr style UserHoverCard |
JS | I 've a problem with my very simple website . It seems that the font size unusually changes in some cases . For instance , when I click on a link in the homepage , the new page opened has a different font size . And it seems that this behavior happens only on Chrome . Please , see the pictures below . For each picture ... | @ charset `` utf-8 '' ; /* CSS Document */body { background-color : # FFF ; font-size:100 % ; font-family : Verdana , Geneva , sans-serif ; } .centered { margin:0 auto ; } .centered-content { text-align : center ; } div.article-header { background-image : url ( ../img/articleheaderback.png ) ; background-position : bot... | Font size unusually changes |
JS | I just started with MEAN stack and i 'm following some TUTs.I 'm using the npm-views from Angular and trying to redirect an html a tag to another html file . However when I go to localhost:3000 I get this : localhost:3000/ # ! / and the when I the link inside that page it simply adds localhost:3000/ # ! / # % 2Fsl.My i... | < ! DOCTYPE html > < html ng-app= '' firstApp '' > < head > < script type= '' text/javascript '' > var app = angular.module ( 'firstApp ' , [ 'ngRoute ' ] ) ; app.config ( function ( $ routeProvider ) { $ routeProvider .when ( '/ ' , { templateUrl : 'home.html ' , controller : 'HomeController ' , } ) .when ( '/sl ' , {... | Why does my url contains `` ! '' when using angular ? |
JS | I spent a fair bit of time on this Javascript issue ( you can tell I am a JS noob ) : Take some well written Javascript code like this example of the Revealing Module Pattern : Running it works fine . Then move the `` { `` to the next line ( as a C # developer I set up all my environments to put curly braces on new lin... | return { someMethod : myMethod , someOtherMethod : myOtherMethod } ; | Why does the { position affects this Javascript code ? |
JS | I 'm using the shopify-buy SDK to try and fetch the articles off of my Shopify store just using JavaScript on the frontend , following the `` Expanding the SDK '' directions here : https : //shopify.github.io/js-buy-sdk/ # expanding-the-sdk.Using the code below , I am able to retrieve my articles and some of the fields... | // Build a custom query using the unoptimized version of the SDKconst articlesQuery = client.graphQLClient.query ( ( root ) = > { root.addConnection ( 'articles ' , { args : { first : 10 } } , ( article ) = > { article.add ( 'title ' ) article.add ( 'handle ' ) article.add ( 'url ' ) article.add ( 'contentHtml ' ) } ) ... | Retrieve article object including its image using the Shopify JavaScript Buy SDK custom query |
JS | 1 . ) What 's the difference between these two queries , exactly ? 2 . ) In the jQuery file itself there is a function that returns the following : What does that mean ? I 've never seen +new before.3 . ) In a brief skimming of a tutorial , I observed the following samples : When I try to reference my own queries by ar... | $ ( `` # orderedlist li '' ) $ ( `` # orderedlist > li '' ) function now ( ) { return +new Date ; } // use this to reset a single form $ ( `` # reset '' ) .click ( function ( ) { $ ( `` form '' ) [ 0 ] .reset ( ) ; } ) ; // use this to reset several forms at once $ ( `` # reset '' ) .click ( function ( ) { $ ( `` form ... | Assorted jQuery questions |
JS | In JavaScript ... I can assume that any string that consists solely of whitespace characters is considered equal to false in JavaScript.According to this article , I figured that false would be converted to 0 , but was unable to find mention of whitespace considered equal to false using Google.Why is this ? Is there so... | '\t\n ' == false // true | Why is ` '\t\n ' == false ` in JavaScript ? |
JS | I have been experimenting with a design pattern in Javascript that would allow me to have what appears to be singleton functions that can be overridden by instance functions.Here 's a brief example : So there are two tomorrow ( ) functions . When called from the Date function directly : But when you instantiate a Date ... | Date.tomorrow = function ( ) { return Date.today ( ) .add ( 1 ) .days ( ) ; } ( function ( p ) { p.tomorrow = function ( ) { var date = this.clone ( ) .clearTime ( ) ; return date.equals ( Date.tomorrow ( ) ) ; } } ) ( Date.prototype ) ; > > > Date.tomorrow ( ) = > Fri Jul 23 2010 00:00:00 GMT-0500 ( CST ) { _orient=1 ... | A ( somewhat obscure ) Javascript inheritance question |
JS | I have this HTML structure : and I must apply a class to the second link , the one without text nodes . I tried `` p : empty a '' and `` p > a : only-child '' but they do n't work ... There is a way to select it using jQuery ? | < div class= '' article-body '' > < p > < a href= '' http : //www.example.com '' > My Link < /a > Lorem Ipsum Dolor Sit amet. < /p > < p > < a href= '' http : //www.example.com '' > Link that I must select. < /a > < /p > < /div > | Selecting < p > elements that have not text nodes in jQuery |
JS | I 'm following some canvas tutorial . The code below is a snippet of that.In this snippet , why would they not choose for runAnimation to be a simple boolean ? I would think the x = ! x statement would work anyways , but when i tried changing the code to use booleans , the code did n't work . So , what 's the differenc... | /* * define the runAnimation boolean as an object * so that it can be modified by reference */ var runAnimation = { value : false } ; // add click listener to canvas document.getElementById ( 'myCanvas ' ) .addEventListener ( 'click ' , function ( ) { // flip flag runAnimation.value = ! runAnimation.value ; | What 's the difference between a boolean as primitive and a boolean as property of an object ? |
JS | I have a weird case with a regular expression in javascript : Is a regular expression type sensitive ? My first goal is to extract all word ( separated by one or more whitespace ) of a string.Thanks for your help.Julien | var re = / [ ^\s ] + ( ? : \s+| $ ) /g ; re.test ( 'foo ' ) ; // return truere.test ( `` foo '' ) ; // return false | Regex test function do not return the same depending quotes |
JS | I have a working real time monitoring program but it 's class architecture is too complex . And this disturbs me really much . Let me start by explaining the program.User InteractionThis is a monitoring program with user interaction . Which means , user can select different dimensions , different metrics , include them... | Req Success OrderFunction 5 60ms WebServer2Req Failed OrderFunction 2 176ms WebServer5Resp Success SuggestFunction 8 45ms WebServer2 | Class Architecture of Monitoring Log Data |
JS | This is a stupid question , and I am aware that it is ; but never the less , here it comes : Is it possible to close a < script > -tag within itself , so to speak ? I mean if you are using an external javascript-document can you close the tag like this : | < script type= '' text/javascript '' src= '' xxx.js '' / > | Closing < script > |
JS | I have a basic SPA ( react ) < - > API ( net core 2.2 ) setup , with 2 environments : dev and prod ( small project ) . There is an authentication mechanism on the API side that checks the presence of a httponly cookie in every request containing a JWT . On the dev environment , it works okey-dokey : allowCredentials ( ... | var request = new XMLHttpRequest ( ) request.open ( 'POST ' , apiAuthenticateUser , true ) request.setRequestHeader ( 'Content-type ' , 'application/json ' ) request.withCredentials = truerequest.send ( postData ) public void Configure ( IApplicationBuilder app , IHostingEnvironment env ) { if ( env.IsDevelopment ( ) )... | Javascript wo n't set httpcookie received in XHR response |
JS | If you try this in Internet Explorer you can see that the dispatched event is not unique during bubbling : Using the equivalent standards-based method : Is there a way to uniquely identify an event in code to work around this lack of functionality ? | var x ; myinnerdiv.onclick = function ( ) { x = window.event ; } ; myparentdiv.onclick = function ( ) { alert ( x === window.event ) ; } ; // false , but should be the same ! var x ; myinnerdiv.onclick = function ( ev ) { x = ev ; } ; myparentdiv.onclick = function ( ev ) { alert ( x === ev ) ; } ; // true : same event... | Check if one event is identical to another during event retargeting in older Internet Explorer |
JS | Let 's say I have an interface : Which then I 'm implementing in several classes : Why TypeScript allows for comparing rectangle and circle ? Should n't it warn me that I provided incompatible type to circle 's equals method ? | interface Comparable < T > { equals ( other : T ) : boolean } class Rectangle implements Comparable < Rectangle > { equals ( other : Rectangle ) : boolean { // logic return true ; } } class Circle implements Comparable < Circle > { equals ( other : Circle ) : boolean { // logic return true ; } } let circle : Circle = n... | Type checking and generics |
JS | I have this code that works great in all browsers but not IE6 , and I have no idea why , can anyone shed any light on this ? | $ ( `` # handle '' ) .toggle ( function ( ) { $ ( ' # login ' ) .animate ( { marginTop : ' 0 ' , } , 1000 ) ; $ ( `` # handle '' ) .addClass ( 'opened ' ) ; return false ; } , function ( ) { $ ( ' # login ' ) .animate ( { marginTop : '-280 ' , } , 1000 ) ; $ ( `` # handle '' ) .removeClass ( 'opened ' ) ; return false ... | jQuery cross-browser issue |
JS | I have group of divs : My JS : My question is , how do I make those three div like a radio button ? So a user can only select one of them ? | < div class= '' row '' > < div class= '' col-xs-12 well bb paylater '' value= '' paylater '' onclick= '' selectPayment ( this ) '' > payment1 < /div > < div class= '' col-xs-12 well bb alipay '' value= '' alipay '' onclick= '' selectPayment ( this ) '' > payment2 < /div > < div class= '' col-xs-12 well bb wechatpay '' ... | How do I select only one div between a group of divs like a radio button ? |
JS | I 'm new to TypeScript and the more I read about modules and namespaces , the more it confuses me . Should I go with modules ? Should I go with namespaces ? should I use both ? help ! I have existing javascript ( .js ) files that I 'm trying to convert to TypeScript . There is one .js file with some general functions a... | namespace Company { // nothing yet , but in future it might . } namespace Company.Project { import Company ; // like this ? let myVar : string = `` something '' ; export function handyGeneralFunction1 ( foo , bar ) { // ... } export function handyGeneralFunction2 ( foo , bar , foo , bar ) { // ... doInternalCalc ( ) ; ... | TypeScript organization : namespaces ? modules ? confusion |
JS | I have array selectedItems and when I try to update existing object : to : It replaces the whole array with : how can I avoid that ? | i.e . [ { lable : `` one '' , uniqueId : 1 } , { lable : `` two '' , uniqueId : 1 } ] i.e . [ { lable : `` one '' , uniqueId : 1 } , { lable : `` two '' , uniqueId : 3 } ] [ { lable : `` two '' , uniqueId : 3 } ] handleChange = ( label , uniqueId ) = > { const { selectedItems } = this.state const findExistingItem = sel... | ReactJS : replacing object from array with new value replaces whole array |
JS | My question is rather elementary , but I do not understand why , in the following code , on button click only button dissapears , instead of the whole div : JSFiddle | < script > function remove ( id ) { //get the element node element = document.getElementById ( id ) ; //remove the element from the document document.removeChild ( element ) ; } < /script > < div id= '' intro '' class= '' jumbotron '' > < h1 > Your Offline Web Dictionary ! < /h1 > < p class= '' lead '' > < div class= '... | javascript - remove element |
JS | I 'm failing to figure out why calling recSetTimeOut ( ) does not result in a stack overflow error , while recPromise ( ) does.Why does it happen ? What is the difference between them ? Can you explain the process behind the scene ? Edit with a bit more of informationRunning this snippets on Node.js v12.1.0 and Chrome ... | const recSetTimeOut = ( ) = > { console.log ( 'in recSetTimeOut ' ) ; setTimeout ( recSetTimeOut , 0 ) } ; recSetTimeOut ( ) ; const recPromise = ( ) = > { console.log ( 'in recPromise ' ) ; Promise.resolve ( ) .then ( recPromise ) ; } recPromise ( ) ; const recSetTimeOut = ( ) = > { setTimeout ( recSetTimeOut , 0 ) ; ... | Why such recursion not getting stack-overflowed ? |
JS | I 'm trying to write code using Ramda to produce a new data structure , using only the id and comment keys of the original objects . I 'm new to Ramda and it 's giving me some fits , although I have experience with what I think is similar coding with Python.Given the following initial data structure…I want to transform... | const commentData = { '30 ' : { 'id ' : 6 , 'comment ' : 'fubar ' , 'other ' : 7 } , '34 ' : { 'id ' : 8 , 'comment ' : 'snafu ' , 'other ' : 6 } , '37 ' : { 'id ' : 9 , 'comment ' : 'tarfu ' , 'other ' : 42 } } ; { ' 6 ' : 'fubar ' , ' 8 ' : 'snafu ' , ' 9 ' : 'tarfu ' } const objFromListWith = R.curry ( ( fn , list )... | How to turn a list of objects into a keyed array/object ? |
JS | I was wondering into the javascript file from the source of http : //www.google.com actually i do it often and try to understand what they have done there . today I was wondering inside the files and found some strange function calls . Maybe its a silly thing but I really have no idea what is it and so that I could n't... | var someFunction = function ( somaeParamenter ) { //do some stuffs ; return something ; } var someOtherThing = ( 0 , someFunction ) ( oneParameter ) ; _.Va = function ( a ) { var b = typeof a ; if ( `` object '' == b ) if ( a ) { if ( a instanceof window.Array ) return `` array '' ; if ( a instanceof window.Object ) re... | Javascript : what does this syntax mean ( 0 , functionName ) ( functionParemeter ) ; |
JS | We have a crazy DOM hierarchy , and we 've been passing JSX in props rather than embedding children . We want the base class to manage which documents of children are shown , and which children are docked or affixed to the top of their associated document 's window.List ( crazy physics writes inline styles to base clas... | render ( ) { return < BaseClass stages= { this.stages ( ) } / > } stages ( ) { if ( ! this._stages ) this._stages = { title : this.title ( ) , content : this.content ( ) } ; return this._stages ; } title ( ) { return [ { canBeDocked : false , jsx : ( < div > A title document row < /div > ) } } content ( ) { return [ { ... | React - proper state management for rows of unmounted JSX ? |
JS | I have a ES7 code like this.What should happen at the var threeP = await three line ? Should the code continue as expected , or fail , because three is not a promise ? In this repo , it is mentioned as `` Debatable Syntax & Semantics '' . I am not able to read through the official documentation to find the exact defini... | async function returnsfive ( ) { var three = 3 ; var threeP = await three ; return threeP+2 ; } returnsfive ( ) .then ( k= > console.log ( k ) , e= > console.error ( `` err '' , e ) ) | What should happen with ` await ` when the expression after the keyword does not evaluate to promise ? |
JS | Looking for a construct in javascript which works like the destructor in stackbased or local object in c++ , e.g.so this means I am looking for a construct which does an action when its scope is ending ( when it `` goes out of scope '' ) . It should be robust in the way that it does not need special action at end of sc... | # include < stdio.h > class M { public : int cnt ; M ( ) { cnt=0 ; } void inc ( ) { cnt++ ; } ~M ( ) { printf ( `` Count is % d\n '' , cnt ) ; } } ; ... { M m ; ... m.inc ( ) ; ... m.inc ( ) ; } // here the destructor of m will printf `` Count is 2 '' ) ; | something like stackbased objects in c++ for javascript |
JS | Short versionI need to divide an audio signal by another one ( amplitude-wise ) . How could I accomplish this in the Web Audio API , without using ScriptProcessorNode ? ( with ScriptProcessorNode the task is trivial , but it is completely unusable for production due to the inherent performance issues ) Long versionCons... | var oscA = audioCtx.createOscillator ( ) ; var oscB = audioCtx.createOscillator ( ) ; var dest = audioCtx.createGain ( ) ; oscA.connect ( dest.gain ) ; oscB.connect ( dest.gain ) ; var dest = audioCtx.createGain ( ) ; var inverter = audioCtx.createGain ( ) ; oscA.connect ( dest.gain ) ; oscB.connect ( inverter ) ; inve... | Dividing one audio signal by another one |
JS | Output in Chrome : Output in Firefox : As I understand , one getting is related to reading value and the other - to assigning.It 's logical that a -- should write to the same place where a was read from . No , it 's not.But getting value for Symbol.unscopables twice hints us , that it 's possible to pass one object for... | with ( new Proxy ( { } , { has ( ) { return true } , get ( obj , key , proxy ) { return console.log ( String ( key ) ) } } ) ) { a -- } Symbol ( Symbol.unscopables ) aSymbol ( Symbol.unscopables ) Symbol ( Symbol.unscopables ) Symbol ( Symbol.unscopables ) a var a , b , flag = truewith ( a = { x : 7 } ) with ( b = { x ... | Why does browser get Symbol.unscopables twice ? |
JS | I 'm filling a progress bar over time using the above javascript to modify its background-image with a gradient.Extremely intermittently -- the background image just entirely stops rendering . I 've placed logging throughout this code and everything seems to be firing properly . I 'm not dividing by 0 , nor is my fill ... | // Repaints the progress bar 's filled-in amount based on the % of time elapsed for current video.progressBar.change ( function ( ) { var currentTime = $ ( this ) .val ( ) ; var totalTime = parseInt ( $ ( this ) .prop ( 'max ' ) , 10 ) ; // Do n't divide by 0. var fill = totalTime ! == 0 ? currentTime / totalTime : 0 ;... | Is there a limit to how often an element 's background-image can be modified ? |
JS | I know this may sound weird but how could I add a transition to a header when it changes it 's size ? The thing is that it has no height related css value , It 's only text with top and bottom padding , and as the text changes , the height does too . So how could I implement something like a transition ? Let me demonst... | $ ( document ) .ready ( function ( ) { $ ( '.header ' ) .click ( function ( ) { if ( $ ( '.header ' ) .html ( ) == 'Hello World ( Click this header ) ' ) { $ ( '.header ' ) .html ( 'Lorem ipsum dolor sit amet , consectetuer adipiscing elit . Praesent dapibus . Nullam eget nisl . Nunc auctor . Morbi leo mi , nonummy ege... | How to add a CSS transition when there are no changing properties ? |
JS | EDITWith the number of responses saying `` you can make private things ! '' below , I 'm going to add this to the top as well : I know you can emulate private variables within a closure . That is not what I 'm asking . I 'm asking , given the two examples below where I 'm `` exporting '' EVERYTHING from the closure , w... | var test = { } test = ( function ( ) { var a_method = function ( print_me ) { return `` hello `` +print_me ; } return { print_me : a_method } ; } ) ( ) ; test.print_me2 = function ( print_me2 ) { return `` hello `` +print_me2 ; } test.print_me ( 'world ' ) ; > > > returns `` hello world '' test.print_me2 ( 'world ' ) ;... | Javascript closures -- what is the difference between these |
JS | From Javascript : The Definitive Guide , What does { x : 1 } do here ? With the braces , it reminds me of function ( or for objects , constructor ) . Can someone please elaborate on it , thanks.An additional related question is : I find this question interesting as well . What is the difference between object and Objec... | var o = { x:1 } ; // Start with an objecto.x = 2 ; // Mutate it by changing the value of a propertyo.y = 3 ; // Mutate it again by adding a new property ( { x:1 , y:2 } ) .toString ( ) // = > `` [ object Object ] '' | What does { x:1 } do in Javascript ? |
JS | I am working on a script to grade a user response by comparing two arrays . ( It is a quiz to see how well they know information word-for-word . ) I already have some of the code that I need , like making the user response lowercase and splitting it . All I need is something to find the number of differences/mistakes .... | var correctanswer = [ `` The '' , '' quick '' , '' brown '' , '' fox '' , '' jumped '' , '' over '' , '' the '' , '' lazy '' , '' dog '' ] ; var useranswer = [ `` The '' , '' brown '' , '' fox '' , '' jumped '' , '' up '' , '' and '' , '' over '' , '' the '' , '' really '' , '' lazy '' , '' cat '' ] ; alert ( counterro... | Use JavaScript to grade user response ( compare two arrays ) |
JS | i 'm having a problem about how can i add an identifier for my row.I have this code to populate the table body using json data.and I have this tableI use this code to test but it does n't work . What could be the error here ? Thanks | var table = `` ; $ .each ( result , function ( i , item ) { table += ' < tr class= '' test '' > < td > ' + item.ip_address + ' < /td > < td > ' + item.app_name + ' < /td > < td > ' + item.crit_severity + ' < /td > < td > ' + item.user_password + ' < /td > < /tr > ' ; } ) ; $ ( `` # tableLinks tbody '' ) .html ( table )... | How to add and manipulate id inside a dynamically generated table rows jquery |
JS | I have the following code in a loop reading the contents of a folder : When the checkbox gets checked I want to have the sizes of each record added up in a separate div : How can I do this ? | < div class= '' oddrow '' > < span class= '' title '' > 1 - 1215 - Magna Carta < /span > < br/ > < span class= '' size '' > size : 229.1 MB < /span > < input name= '' 1215 - Magna Carta '' type= '' checkbox '' > < div > < div id= '' total > total = < /div > | Sum the contents of divs when their corresponding checkbox is clicked |
JS | I 've made an NPM package for react , it 's working fine on Node but it 's not working on browser without node.if I import within node like this : It 's working fine.But if I use it from CDN like unpkg , it 's not working . It 's showing an error : Progress is not definedCan anyone please help me about this issue ? Web... | import Progress from 'package-name'// jsx < Progress / > //working fine < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.js '' > < /script > < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.js '' > < /script > // Package Script < script src= '' https : //unpkg... | Javascript : How do I use React component globally ? |
JS | Hi I 'm currently working on a parallax website . I would like to add an image that moves down as the user scrolls ... but ONLY within a section of a website . So 4 sections down..the image is there ... it moves as the user scrolls down ... then disappears behind 5th section and we see it no more.I 'm trying to do a si... | // Create cross browser requestAnimationFrame method : window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function ( f ) { setTimeout ( f , 1000/60 ) } var bubble1 = document.getElementById ( 'bubbles1... | how to confine animated div to a webpage section ? |
JS | I have a array like this.Am converting every element to string so as to use with jquery autocomplete.Am using .map function to do this.output is Function is taking 0111,0112,0113,0142 all these values as Octal values and converting them to decimal.I do n't want this conversation and want to preserve leading Zero also ,... | var elements= [ 5614,6619,7220,7320,7830,8220,0111,0112,0113,0142,0149 ] elements = elements.map ( String ) ; [ `` 5614 '' , `` 6619 '' , `` 7220 '' , `` 7320 '' , `` 7830 '' , `` 8220 '' , `` 73 '' , `` 74 '' , `` 75 '' , `` 98 '' , `` 149 '' ] | Javascript map function converting values to decimal |
JS | I have a row which contains four panels . I want the height of all panels in same height . For example : Due to addition of content in the second panel , the height of it changed a bit and it is not in the same height as other panels.I want the height of all other panels to be changed automatically.I have give a minimu... | < div class= '' container-fluid '' > < div class= '' row '' > < div class= '' col-md-3 '' > < div class= '' panel panel-default '' style= '' min-height:250px ; '' > < div class= '' panel-body '' > Panel < /div > < /div > < /div > < /div > < /div > | Adjust the height of all panels in a row according to the content |
JS | Is it possible to bind a function to another function on invoke ? So for example , it would go something like this : So when b is called , a is also automatically called.EDIT : OK OK , to clarify , this is not a question on chaining . The idea is to find an elegant way to do event binding . Observe the normal `` non-el... | function a ( ) { ... } function b ( ) { ... } b.bind ( `` onInvoke '' , '' a '' ) ; function handler ( ) { ... } function caller1 ( ) { handler ( ) ; ... } function caller2 ( ) { handler ( ) ; ... } function caller2 ( ) { handler ( ) ; ... } // More callers all over your website everywhere else function handler ( ) { .... | Function invoked event in JS ? |
JS | I have a form , which has multiple tabs that displays 10 questions in each one and include ( true/false ) radio groups ( generated by php code , so I do n't know their names OR how many will appear ) , and I need to check whether they are checked or not on next button clicked . If not I want to show the user which ques... | < form id= '' questionForm '' action= '' '' method= '' post '' role= '' form '' > < input type= '' hidden '' name= '' login '' value= '' < ? php echo $ _SESSION [ 'login-user ' ] ? > '' / > < input type= '' hidden '' name= '' pass_user '' value= '' < ? php echo $ _SESSION [ 'pass_user ' ] ; ? > '' / > < ? php $ blocks_... | validate a multiple tabs with multiple radio buttons |
JS | I was reading John Resig 's Learning Advanced JavaScript slides.As i came to the slide-27 , john presents a quiz as per below : QUIZ : How can we implement looping with a callback ? I tried to implement , and came up with following code : I was happy that it worked , and eager to see the next slide to compare it with s... | function loop ( array , fn ) { for ( var i = 0 ; i < array.length ; i++ ) { // Implement me ! } } var num = 0 ; loop ( [ 0 , 1 , 2 ] , function ( value ) { assert ( value == num++ , `` Make sure the contents are as we expect it . `` ) ; assert ( this instanceof Array , `` The context should be the full array . `` ) ; }... | A possible solution for function looping |
JS | Out of just intellectual curiosity , why does javascript accept to initialize z ( as z may defined initially ) but without var , it throws an error ( in global space ) ( if z is previously undefined ) In the global space you are not required to use VAR though I get it might be bad practice.Before you say this is a dupl... | var z = z || [ ] ; z = z || [ ] ; | Javascript : z = z || [ ] throws an error when not using VAR - why ? |
JS | I 'm using baguettebox for image viewer . The problem is , everything works except the `` next/previous '' buttons . So I ca n't go to the next image.and the html : My result : https : //i.gyazo.com/3e9bad7f104794962a31b8ef13ce0891.pngAs you can see , there are n't next/prev buttons , only the X which works fine . | < script src= '' https : //code.jquery.com/jquery-3.3.1.slim.min.js '' integrity= '' sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo '' crossorigin= '' anonymous '' > < /script > < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js '' integrity= '' sha384-... | Baguettebox does n't show next/previous stepper |
JS | I would like to use the Fetch API in a browser extension to download a resource and compute a hash thereof . The following works ( using crypto through Browserify ) but has the disadvantage that I have to wait for a.onloadend while the context in which I 'd like to embed it requires a Promise to be returned . Also , it... | fetch ( url ) .then ( function ( response ) { return response.blob ( ) ; } ) .then ( function ( data ) { var a = new FileReader ( ) ; a.readAsBinaryString ( data ) ; a.onloadend = function ( ) { var hash = crypto.createHash ( hashType ) ; hash.update ( a.result , 'binary ' ) ; return hash.digest ( 'hex ' ) ; } ; } ) | fetch resource , compute hash , return promise |
JS | Let 's consider I have the following codeI have just lost the .length data on _fun because I tried to wrap it with some interception logic.The following does n't workThe annotated ES5.1 specification states that .length is defined as followsGiven that the logic inside fun requires .length to be accurate , how can I int... | /* ... */var _fun = fun ; fun = function ( ) { /* ... */ _fun.apply ( this , arguments ) ; } var f = function ( a , b ) { } ; console.log ( f.length ) ; // 2f.length = 4 ; console.log ( f.length ) ; // 2 Object.defineProperty ( fun , `` length '' , { value : /* ... */ , writable : false , configurable : false , enumera... | Wrapping functions and function.length |
JS | I have created two Mean.io apps in domain.com and in sub.domain.com respectively and everything works as expected in both but the problem is that the one in the subdomain ( sub.domain.com ) needs to know if the user is logged in the main app ( domain.com ) .I know that passport handles sessions and knows if user is log... | if ( req.user ) { // logged in } else { // not logged in } $ http.get ( '/api/users/me ' ) .success ( this.onIdentity.bind ( this ) ) ; | How to know if user is loggedin in with passport.js across subdomains |
JS | I 'm trying to do some simple DOM manipulation on several elements at once with jQuery using each ( ) . I 'm getting results that I do n't understand . Here is a jsFiddle that shows what I want to happen VS what actually happens : http : //jsfiddle.net/kthornbloom/4T52A/2/And here is the JS : Why am I getting the resul... | // Step One : Append one blue box within each grey box $ ( '.grey ' ) .append ( ' < div class= '' blue '' > < /div > ' ) ; // Step Two : Make one copy of the red box already there , and place it within the new blue box. $ ( '.grey ' ) .each ( function ( ) { $ ( '.red ' , this ) .clone ( ) .appendTo ( '.blue ' , this ) ... | jQuery DOM manipulation with each ( ) ; |
JS | I have noticed a difference between the data before returning and after a return of a component . My former question was going to be `` How to read rendered component 's className ? `` , but I have split the questions as answering what is actually happening and why is it like that really started to bug me and might eve... | class AComponent extends Component { render ( ) { const body = < BComponent crmStatus= { ... } / > debugger // log body on the right // ... render as static html to electron window return false } } class BComponent extends Component { render ( ) { const resultRender = < article className='large ' > ... < /article > deb... | What actually happens when React component returns ? |
JS | I am trying to implement MVC using AMD in canjs . For that I am using requirejs.This is my domains.json file : This is my domainModel : This is my controller : This is my main js : I am tracing out my code.I put breakpoints.On model breakpoints I am not getting values in local variables in chrome devtools.The url prope... | [ `` 1 '' : { `` uid '' : `` 1 '' , '' urls '' : `` domain1.abc.com '' } , '' 2 '' : { `` uid '' : `` 2 '' , '' urls '' : `` domain2.abc.com '' } , '' 3 '' : { `` uid '' : `` 3 '' , '' urls '' : `` domain3.abc.com '' } ] define ( [ 'can ' ] , function ( can ) { SearchModel= can.Model ( { id : 'uid ' , findAll : 'GET /d... | can-model can not getting data from .json file |
JS | RegExp /\c/ does n't trigger any syntax error.The question is why it 's not a syntax error . Since the language spec , I 'm guessing Pattern → Disjunction → Alternative → Term → Atom → \ AtomEscape → CharacterEscape → IdentityEscape , then it arrives at SourceCharacter but not c and it does n't match by the condition b... | console.log ( /\c/ ) | RegExp /\c/ in JavaScript |
JS | Looking to see if an order line_item has been refunded before processing ... Here is a single order : Trying to log out the filter results : I 'm getting 0 on the console . Am I using _.filter wrong in this case ? | var order = { line_items : [ { id : 1326167752753 } ] , refunds : [ { refund_line_items : [ { id : 41264152625 , line_item_id : 1326167752753 , } ] } ] } ; console.log ( _.filter ( order , { refunds : [ { refund_line_items : [ { line_item_id : 1326167752753 } ] } ] } ) .length ) ; | lodash filter not finding value in multidimensional array of Shopify order |
JS | Is there a way to output all model data of polymer elements ? I would like to output each property and their value to the view.I know vue accomplishes this , by usingBut Vue also has a data attribute that is dumpable . Not sure if it is even possible in polymer to dump every property and their value into the view.I 'd ... | { { $ data | json } } { { $ properties } } | PolymerJS : How to output Model data ? |
JS | I created a Graph using ZingChart library and everything is working as expected . The graph is used to show the power consumption of a specific outlet over time . When the graph is loaded the system shows the kWh consumption for that time period . The user was the ability to zoom in and out the graph , and when that ha... | zingchart.render ( { id : 'chartDiv ' , data : graphset , height:500 , events : { zoom : function ( p ) { console.log ( p ) ; console.log ( zingchart.exec ( p.id , 'getseriesdata ' , { } ) ) ; console.log ( zingchart.exec ( p.id , 'getseriesvalues ' , { } ) ) ; console.log ( zingchart.exec ( p.id , `` getplotvalues '' ... | ZingChart JS - Get visible nodes |
JS | I am writing a program to find the best possible MLB lineup using a knapsack solution . For this I pass in player data which has a players calculated value and salary . The salary will be my `` weight '' in terms of being a knapsack problem.My problem is not be able to select players , but rather select the most optima... | CalculateLineUp.prototype.findOptimalLineUp = function ( data , capacity ) { var items = data.data ; var idxItem = 0 , idxCapSpace = 0 , idxPosition = 0 , oldMax = 0 , newMax = 0 , numItems = items.length , weightMatrix = new Array ( numItems+1 ) , keepMatrix = new Array ( numItems+1 ) , positionArray = new Array ( `` ... | Optimal MLB lineup using Knapsack variant |
JS | My auth is based on 2 things : firebase auth ( email/password ) call on a server API to retrieve full customer entity from BDD and from firebaseID ( user must exists ) So a user will be `` authenticated '' if these two conditions are met.I also have authGuards based on a isAuthenticated ( ) returning an Observable ( be... | export class AuthService { public userRole : UserBoRole ; public authState $ : Observable < firebase.User > ; constructor ( private afAuth : AngularFireAuth , private snackBar : SnackBarService , private translate : TranslateService , private router : Router , private grpcService : GrpcService ) { this.authState $ = th... | AngularFirebaseAuth : Calling server api just after firebase auth ? |
JS | If i consider an example this opens login page in my app . But if the link is like this does n't open the login page in App because the Path is not defined in routesNow the requirement is , whenever a user clicks on Second link , even then it should open login component in App and not in web . ie . multiple routes for ... | https : //app.abc.com/login https : //app.abc.com/loginUser //This link is a route in web app | Opening DeepLinks which are not specified in Routes in react-native |
JS | I 'm working with OffCanvasMenuEffects and i 'm using wave menu effect . You can see this menu in following : Currently the Menu opens from bottom to top.My question is how is it possible to change the position of how the off canvas menu loads , default is bottom to top with wave effect convert to top to bottom , like ... | article , aside , details , figcaption , figure , footer , header , hgroup , main , nav , section , summary { display : block ; } audio , canvas , video { display : inline-block ; } audio : not ( [ controls ] ) { display : none ; height:0 ; } [ hidden ] { display : none ; } html { font-family : sans-serif ; -ms-text-si... | How to change animation position in Off-Canvas Menu Effects |
JS | I 'm having a small problem with MomentJS returning a nonsense date . I am attempting to set the date to the first of a given month and year . I have tried the following : -This gives Thursday , 4th October 2015 as the _date . Which does n't exist . I tried using .set ( ) and .date ( ) , both give the same result : -So... | var _year = 2015 ; var _month = 10 ; var _dateString = _year.toString ( ) + '- ' + _month.toString ( ) + '-1 ' ; var _date = moment ( _dateString , 'YYYY-MM-D ' ) ; console.log ( '_date ' , _date.format ( 'dddd , do MMMM YYYY ' ) ) ; var _date = moment ( _dateString , 'YYYY-MM-D ' ) .set ( 'date ' , 1 ) ; > Thursday , ... | MomentJS returns obscure date for 1st of month |
JS | Every now and then some JavaScript function I 'm working on would just quit quietly , without anything indicating in any way that something out of the ordinary has occurred.This is driving me insane . Surely there must be a way to turn on some sort of `` I 'm a developer '' flag so that things like this will throw a bi... | window.setTimeout ( function ( ) { alert ( 'Entered ! ' ) ; foo ; alert ( 'Exited ! ' ) ; } , 300 ) ; | Can I put an end to quiet deaths of JavaScript functions ? ( Does setTimeout swallow exceptions ? ) |
JS | Trying to solve this kata on Codewars.I 've been able to reverse the array into a string , but have n't been able to assign this string into individual elements of a specified length . I tried : But the outcome that we want is : [ `` ! `` , `` eilt '' , `` onn '' , `` acIdn '' , `` ast '' , `` t '' , `` ubgibe '' , `` ... | function ultimateReverse ( array ) { let newArray = array.join ( `` '' ) .split ( `` '' ) ; let reversedArray = newArray.reverse ( ) ; return reversedArray.join ( `` '' ) ; } console.log ( ultimateReverse ( [ `` I '' , `` like '' , `` big '' , `` butts '' , `` and '' , `` I '' , `` can not '' , `` lie ! `` ] ) ) ; // !... | Reverse Array , Let Elements in New Array Equal Length of Original Array Elements - JavaScript |
JS | One of the features introduced by ECMAScript 6 is the ability to indicate default values for unspecified parameters in JavaScript , e.g.Now I 'm wondering if it 's possible to use default parameters also for functions created dynamically with the Function constructor , like this : Firefox 39 seems to already support de... | function foo ( a = 2 , b = 3 ) { return a * b ; } console.log ( foo ( ) ) ; // 6console.log ( foo ( 5 ) ) ; // 15 new Function ( ' a = 2 ' , ' b = 3 ' , 'return a * b ; ' ) ; | Dynamically create a function with default parameters in JavaScript |
JS | I 'm developing an add-on for the first time . It puts a little widget in the status bar that displays the number of unread Google Reader items . To accommodate this , the add-on process queries the Google Reader API every minute and passes the response to the widget . When I run cfx test I get this error : Error : The... | // main.js - Main entry pointconst tabs = require ( 'tabs ' ) ; const widgets = require ( 'widget ' ) ; const data = require ( 'self ' ) .data ; const timers = require ( `` timers '' ) ; const Request = require ( `` request '' ) .Request ; function refreshUnreadCount ( ) { // Put in Google Reader API request Request ( ... | Error : The page has been destroyed and can no longer be used |
JS | How to get the changed state after an async action , using React functional hooks ? I have found a redux solution for this issue , or a react class component solution , but I am wondering if there is a simple react functional solution.Here is the scenario : create a functional react component with . few statescreate se... | import React , { useState } from `` react '' ; import `` ./styles.css '' ; export default function App ( ) { const [ counter , setCounter ] = useState ( 0 ) ; const [ asyncCounter , setAsyncCounter ] = useState ( 0 ) ; return ( < div className= '' App '' > < div > < button onClick= { async ( ) = > { //sets the asyncCou... | How to get the changed state after an async action , using React functional hooks |
JS | Some pages are n't correctly received on mobile phones ( many ones in France ) : JavaScript script elements are inlined.Instead of having I haveAs the Content Security Policy header I set forbids inline scripts , modern browsers block the execution of the script . Is there a way to deal with that other than using HTTPS... | < script src= '' static/jquery-2.1.3.min.js '' > < /script > < script > ... content of the whole jQuery script ... < /script > | My scripts are inlined by some mobile carriers - How to deal with that ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.