Converting lodash's `_.pull` to vanilla JS? I'm having an issue with this function that recursively removes empty values from an object:  const _ = require('lodash')  function sanitize(object) {   Object.entries(object).forEach(([key, val]) =&gt; {     if (       val == null ||       Number.isNaN(val) ||       (typeof val === 'string' &amp;&amp; isOnlyWhitespace(val)) ||       (typeof val === 'object' &amp;&amp; Object.keys(sanitize(val)).length === 0)     ) {       delete object[key]     }   });      // Remove `undefined` values leftover from using `delete` on an array.   if (Array.isArray(object)) {     _.pull(object, undefined); // THIS IS THE LINE IM TRYING TO CHANGE   }    return object; }  function isOnlyWhitespace(str) {   return !(/\S/).test(str.trim()); }   I'm trying to replace _.pull(object, undefined) with vanilla JS, but nothing seems to give the right output (I've tried using stuff like filter.)  Here is a snippet you can run to see both outputs:    // LODASH VERSION function lodashSanitize(object) {   Object.entries(object).forEach(([key, val]) =&gt; {     if (       val == null ||       Number.isNaN(val) ||       (typeof val === 'string' &amp;&amp; isOnlyWhitespace(val)) ||       (typeof val === 'object' &amp;&amp; Object.keys(lodashSanitize(val)).length === 0)     ) {       delete object[key]     }   });    // Remove `undefined` values leftover from using `delete` on an array.   if (Array.isArray(object)) {     _.pull(object, undefined); // THIS IS THE LINE IM TRYING TO CHANGE   }    return object; }  // MY VERSION function mySanitize(object) {   Object.entries(object).forEach(([key, val]) =&gt; {     if (       val == null ||       Number.isNaN(val) ||       (typeof val === 'string' &amp;&amp; isOnlyWhitespace(val)) ||       (typeof val === 'object' &amp;&amp; Object.keys(mySanitize(val)).length === 0)     ) {       delete object[key]     }   });    // Remove `undefined` values leftover from using `delete` on an array.   if (Array.isArray(object)) {     object = object.filter(val =&gt; val != null) // THIS IS MY ATTEMPT   }    return object; }  function isOnlyWhitespace(str) {   return !(/\S/).test(str.trim()); } &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"&gt;&lt;/script&gt; &lt;button id="lodash"&gt;Show lodash output&lt;/button&gt; &lt;button id="me"&gt;Show my output&lt;/button&gt; &lt;p id="output" /&gt; &lt;script&gt;   /**    * Fiddle-related code, you can ignore this    */    const lodashBtn = document.querySelector('#lodash')   const meBtn = document.querySelector('#me')   const output = document.querySelector('#output')      function createExampleInput() {     const input = {       name: 'John',       grades: [         90,         undefined,         50,         null       ]     };          return input;   }      lodashBtn.addEventListener('click', () =&gt; {     output.textContent = JSON.stringify(lodashSanitize(createExampleInput()), null, 4)   });      meBtn.addEventListener('click', () =&gt; {     output.textContent = JSON.stringify(mySanitize(createExampleInput()), null, 4)   }); &lt;/script&gt;
Remove empty elements from an array in Javascript How do I remove empty elements from an array in JavaScript?   Is there a straightforward way, or do I need to loop through it and remove them manually?
In my profile I saw this:     Accounts (48) - 1 hidden account   as seen in this image:        So, what is this "hidden account"? And how do I see it? Usually \label does not create any white spaces. However, It creates an white space when \label is used after \phantomsubcaption from subcaption package.   Why? How can I get rid of this white space?   Here is a MWE:  \documentclass{article} \usepackage{subcaption}  \begin{document}  \section{a} a\label{sec:a}b% no white space between `a' and `b'  \begin{figure}   \centering   {a\phantomsubcaption\label{fig:a}}%   {b\phantomsubcaption\label{fig:b}}   \caption{With label}% undesired white space between `a' and `b' \end{figure}  \begin{figure}   \centering   {a\phantomsubcaption}%   {b\phantomsubcaption}   \caption{Without label}% no white space between `a' and `b' \end{figure}  \end{document} Prove $[0, 1]$ and $(0, 1]$ are equinumerous by use of bijection What my thought was that the bijection was a piecewise function:  $f(x) = 1/n+1$ if $x = 1/n$ for some $n \in \Bbb N$ and $x=1/n$ if $x \neq1/n$ for some $n \in \Bbb N$.  However, the textbook says this is incorrect. I don't actually see why. Was it a matter of brackets or the open variable $(0,1]$, which is what I tend to think. Direction of friction when a car turns When a ball moves to the right, friction acts to oppose the motion, in other words, to the left. However, when a car travels around a bend, the friction acts in the perpendicular direction to the car's velocity and provides the centripetal force. I just cannot understand why friction would act in that direction. explicit formula for recurrence relation $a_{n+1}=2a_n+\frac{1}{a_n}$ For $n\in\mathbb N$, $$a_{n+1}=2a_n+\frac{1}{a_n},\quad a_1=1. $$ Can any one give an explicit formula for all $a_n$? If such an explicit general formula doesn't exist, please explain it. I've tried to figure out the $n$-iterated function $f^{(n)}$ where $f(x)=2x+1/x$ or even $f(\tan(t))$. But in either cases, I failed.Since the recurrence isn't linear nor homogeneous,the generating function method doesn't apply here. mysqli or PDO - what are the pros and cons? If A is an infinite set and B is at most countable set, prove that A and $A \cup B$ have the same cardinality I am trying to prove: If A is an infinite set and B is at most countable set, prove that A and $A \cup B$ have the same cardinality.  Set definitions here are from baby Rudin.   Attempt: There are 4 possible cases:  1.A is countable and B is finite.  2.A is countable and B is countable.  3.A is uncountable and B is finite.  4.A is uncountable and B is countable.  Then for each case I need to show that $A \cup B \sim A$. I can prove 1-3, but I am unsure how to prove case 4. And in general, it seems that my proof strategy is inefficient and there exist much faster proof then proof by cases. It's known that when you're connecting to a wrong server via ssh and send your password  to it, your password comes in a plain text and a server saves it by default. Probably. I wonder, where I can retrieve it? I don't see it in /var/log/auth.log, although I do see all the attempts to authenticate. How to read a text file into GNU R with a multiple-byte separator? Probability of first actor winning a "first to roll seven with two dice" contest? Two players P and Q take turns, in which they each roll two fair and independent dice. P rolls the dice first.  The first player who gets a sum of seven wins the game. What is the probability that player P wins the game? I admin a handful of cloud-based (VPS) servers for the company I work for.   The servers are minimal ubuntu installs that run bits of LAMP stacks / inbound data collection (rsync). The data is large but not personal, financial or anything like that (ie not that interesting)  Clearly on here people are forever asking about configuring  and such like.   I use a bunch of approaches to secure the servers, for example (but not restricted to)   ssh on non standard ports; no password typing, only known ssh keys from known ips for login etc https, and restricted shells (rssh) generally only from known keys/ips servers are minimal, up to date and patched regularly use things like rkhunter, cfengine, lynis denyhosts etc for monitoring   I have extensive experience of unix sys admin. I'm confident I know what I'm doing in my setups. I configure /etc files. I have never felt a compelling need to install stuff like firewalls: iptables etc.  Put aside for a moment the issues of physical security of the VPS.  Q? I can't decide whether I am being naive or the incremental protection a fw might offer is worth the effort of learning / installing and the additional complexity (packages, config files, possible support etc) on the servers.  To date (touch wood) I've never had any problems with security but I am not complacent about it either. Adding a Link to a Field in a Field Set? String queryFields = null;              for(Schema.FieldSetMember field : SObjectType.Task.FieldSets.Activity_Detail_Page.getFields()){                  queryFields = (queryFields == null ? field.getFieldPath() : queryFields+', '+field.getFieldPath());               }                String query = 'Select '+queryFields+' from Task where Id=\''+activityId+'\'';               task = Database.query(query);   i'll creating a field-set,now how do i add link on any field?  above code is  for dynamically query creation . below code of page   &lt;apex:pageBlock title="Activity" id="Block1"&gt;       &lt;apex:pageBlockSection title="Activity Detail"&gt;         &lt;apex:repeat value="{!$ObjectType.Task.FieldSets.Activity_Detail_Page}" var="field"&gt;             &lt;apex:outputField value="{!Task[field.fieldPath]}" /&gt;         &lt;/apex:repeat&gt;     &lt;/apex:pageBlockSection&gt; &lt;/apex:pageBlock&gt;    As per the image attached, I want to add a link in Rounded field that liks to account. Can any one help me? Adding two numbers concatenates them instead of calculating the sum Let A,B be in $M_{mxn}(\mathbb{R})$  Prove that if rank(A + B) = rank(A) + rank(B), then col(A) ∩ col(B) = {0}  I started with a proof by contradiction, since we know that rank(A + B) ≤ rank(A) + rank(B). I assume that if rank(A + B) &lt; rank(A) + rank(B), then col(A) ∩ col(B) = {0}. I realize that we don't have to do the > case. However I am a little confused on how to show col from rank. How to create a soft or symbolic link? Is there a function in python to split a word into a list? I found an example in the  for Dynamic LINQ that allows you to use a sql-like string (e.g. OrderBy("Name, Age DESC")) for ordering. Unfortunately, the method included only works on IQueryable&lt;T&gt;. Is there any way to get this functionality on IEnumerable&lt;T&gt;? Proof of $a^n+b^n$ divisible by $a+b$ when $n$ is odd What are preimage resistance and collision resistance, and how can the lack thereof be exploited? What is "preimage resistance", and how can the lack thereof be exploited? How is this different from collision resistance, and are there any known preimage attacks that would be considered feasible? How do I know if my Australian ETA was approved?