HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div id="page-wrap">
<h1>Every Method in JavaScript</h1>
<h2 class="subtitle">All Built-In Methods in JavaScript</h2>
<p>Ever wonder exactly which methods are available on every JavaScript object? I did, plus I wanted to write a post listing all of them with links to more detail for each. So, I needed a tool. This is that tool.
</p>
<p>This tool grabs the available JavaScript objects and lists each with every method available on that object. It will also link each to MDN's write-up on it (if available).</p>
<p>There are lists on MDN and other places of objects and methods, but I could not find anywhere with every object and every method all on one page, so this tool was my answer to obtain that.</p>
<p>It will take about 4 - 7 minutes to complete its work. The links will be shown in black, except for the inherited methods, these will be shown in gray.</p>
<button id='start-button'>Start</button>
<div id="loading-wrap">
<div id="loader" class="hidden">
<p>We are now pulling each object and method from the browser and building the complete list. This will take between four to seven minutes. Stand by and watch the progress.</p>
<div id="count-wrap"><p>We have completed <span id="count-box"></span>% of the work.</p>
<p id="timeholder" class="hidden">Total time taken: <span id="time"></span> minutes.</p>
</div>
</div>
</div>
<p><a href="https://www.glassinteractive.com/every-method-in-javascript/" target="_blank" >If you do not want to wait, the full list saved here →</a></p>
<div id="method-list-wrap">
<div class="loader-wrap">
<div class="loader loader8">
<div class="loader8inner"></div>
<div class="loader8inner"></div>
<div class="loader8inner"></div>
</div>
</div>
</div>
</div>
body {margin: 0;}
#page-wrap{
background-color: black;
color: white;
padding: 1em 2em;
width: 100%;
min-height: 100vh;
}
p {
max-width: 500px;
}
#method-list-wrap {
display: flex;
flex-wrap: wrap;
justify-content: center;
}
#method-list-wrap .method-list {
display: block;
flex-direction: column;
position: relative;
/* max-height: 25em; */
overflow: hidden;
padding: 0 2em 2em;
margin: 1em;
box-shadow: -1em -1em 1em -1em #bdbdbd inset;
transition: 2s all ease;
/* transition-delay: 0.5s; */
border-radius: 0.25em;
/* height: 25em; */
transition-timing-function: cubic-bezier(0.24, 0.76, 1, 0.3);
list-style: none;
background: white;
color: black;
}
.method-specific {
background: #06649e;
color: white;
font-weight: 700;
padding: 0.25em 0.5em 0.25em 0.25em;
border-radius: 0.25em;
line-height: 2em;
}
.inherited-method {
opacity: 0.5;
/* font-weight: 700; */
color: inherit;
transition: 0.3s all ease;
}
.inherited-method:hover {
opacity: 1;
}
.inherited-method:hover:after {
content: "Inherited Method";
position: absolute;
font-size: 0.7em;
margin-left: 1em;
}
.hidden {
display: none;
}
#loading-wrap {
position: relative;
width: 28em;
background: black;
color: white;
}
#loader {
background: black;
color: white;
padding: 2em;
}
#loader:after {
position: relative;
content: '';
display: block;
background: #131417;
color: white;
width: 50px;
height: 50px;
animation: movement 7s linear infinite;
box-shadow: inset -7px -7px 10px -7px rgb(0 0 0 / 0.5), inset 7px 7px 10px -7px white;
}
@keyframes movement {
0% {
background-color: black;
border-radius: 50%;
transform: translate(-70%) scale(0.1, 1);
left: 0;
}
25% {
background-color: orangered;
border-radius: 50%;
transform: translate(-70%) scale(1.5);
left: 50%
}
50% {
background-color: darkcyan;
border-radius: 50%;
transform: translate(-70%) scale(0.1,1);
left: 100%
}
75% {
background-color: yellowgreen;
border-radius: 50%;
transform: translate(-70%) scale(0.5);
left: 50%
}
100% {
background-color: blueviolet;
border-radius: 50%;
transform: translate(-70%) scale(0.1, 1);
left: 0;
}
}
let startTime;
function beginSearch() {
toggleLoader()
startTime = timer()
setTimeout(function() {
runTheSearch()
}, 1000);
}
function finish(startTime) {
console.log('*** FINISHED! ***')
timer(startTime)
}
function toggleLoader() {
const loader = document.getElementById('loader');
loader.classList.toggle('hidden');
console.log('Loader toggled')
}
function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
function timer(startTime) {
if(startTime) {
console.log('startTime',startTime)
let stopTime = performance.now();
const timeTaken = millisToMinutesAndSeconds((stopTime - startTime).toFixed(0));
let timeHolder = document.getElementById("timeholder");
let time = document.getElementById("time");
timeHolder.classList.toggle('hidden')
time.innerText = timeTaken;
} else {
console.log('Timer started')
return performance.now();
}
}
const getMethods = (obj) => {
let properties = new Set();
let currentObj = obj;
do {
Object.getOwnPropertyNames(currentObj).map((item) =>
properties.add(item)
);
} while ((currentObj = Object.getPrototypeOf(currentObj)));
return [...properties.keys()].filter((item) => {
if (
item != "arguments" &&
item != "caller" &&
item != "callee" &&
item != "__proto__" &&
item != "__defineGetter__" &&
item != "__defineSetter__" &&
item != "__lookupGetter__" &&
item != "__lookupSetter__" &&
typeof obj[item] === "function"
) {
return true;
}
}); //
};
const makeMethodList = function (theType, typeName) {
typeName = typeName || theType.name;
let allMethods = [];
// const typeLowerCase = theType.toLowerCase();
try {
allMethods = getMethods(theType.prototype);
} catch (error) {
// console.log(error);
// if (error) allMethods.push('*');
}
try {
allMethods.push(...getMethods(theType));
} catch (error) {}
try {
allMethods.push(...getMethods(new theType()));
} catch (error) {}
allMethods.sort();
allMethods = new Set(allMethods);
const listArray = [];
allMethods.forEach((method) => {
const listItem = document.createElement("li");
listItem.setAttribute("id", method + "-link");
listItem.className = "general-method-listitem";
const theLink = document.createElement("a");
theLink.setAttribute("target", "_blank");
theLink.className = "general-method-link";
var url =
"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/" +
typeName +
"/" +
method;
(async () => {
let response = await new Promise((resolve) => {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, false);
xhr.onload = function (e) {
resolve(xhr.response);
};
xhr.onerror = function () {
resolve(undefined);
console.error("** An error occurred during the XMLHttpRequest");
};
try {
xhr.send();
} catch (error) {}
console.log(xhr.status);
if (xhr.status != 200) {
theLink.setAttribute(
"href",
"https://developer.mozilla.org/en-US/search?q=" + method
);
theLink.classList.add("inherited-method");
} else {
theLink.setAttribute(
"href",
"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/" +
typeName +
"/" +
method
);
theLink.classList.add("method-specific");
}
theLink.appendChild(document.createTextNode(method));
listItem.appendChild(theLink);
listArray.push(listItem);
});
})();
// theLink.setAttribute(
// "href",
// "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/" +
// typeName +
// "/" +
// method
// );
// theLink.appendChild(document.createTextNode(method));
// listItem.appendChild(theLink);
// listArray.push(listItem);
});
const theUL = document.getElementById("method-list-wrap");
const ulWrap = document.createElement("ul");
ulWrap.setAttribute("id", typeName + "-ul");
ulWrap.setAttribute("target", "_blank");
ulWrap.className = "method-list grid-item";
const ulTitle = document.createElement("h3");
ulTitle.appendChild(document.createTextNode(typeName + " Methods"));
ulWrap.appendChild(ulTitle);
listArray.forEach((link) => {
// console.log(link)
ulWrap.appendChild(link);
});
theUL.appendChild(ulWrap);
};
let cnt = 0;
function runTheSearch() {
const jsObjectArray = [
Function,
Object,
Array,
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array,
BigInt64Array,
BigUint64Array,
String,
RegExp,
Symbol,
Boolean,
Number,
BigInt,
Math,
Date,
Map,
Set,
WeakMap,
WeakSet,
EventTarget,
Error,
EvalError,
RangeError,
ReferenceError,
SyntaxError,
TypeError,
URIError,
ArrayBuffer,
[SharedArrayBuffer, "SharedArrayBuffer"],
[Atomics, "Atomics"],
DataView,
[JSON, "JSON"],
Promise,
[Reflect, "Reflect"],
Proxy,
[Intl, "Intl"],
Intl.Collator,
Intl.DateTimeFormat,
Intl.ListFormat,
Intl.NumberFormat,
Intl.PluralRules,
Intl.RelativeTimeFormat,
Intl.Locale,
[WebAssembly, "WebAssembly"],
WebAssembly.Module,
WebAssembly.Instance,
WebAssembly.Memory,
WebAssembly.Table,
WebAssembly.CompileError,
WebAssembly.LinkError,
WebAssembly.RuntimeError,
/*globalThis,*/
];
let cnt = 0;
jsObjectArray.forEach((obj) => {
// This is moved out of the thread
// to preventblocking updating the DOM
setTimeout(createEntry, 1000);
function createEntry() {
console.log("obj", obj);
if (!obj[1]) {
makeMethodList(obj);
} else {
makeMethodList(obj[0], obj[1]);
}
cnt++;
const cntBox = document.getElementById('count-box');
const cntPercentage = cnt/jsObjectArray.length * 100;
cntBox.innerText = cntPercentage.toFixed(2);
console.log('cntPercentage >= 1', cntPercentage >= 1)
if(cntPercentage >= 100) finish(startTime);
}
});
}
const startBtn = document.getElementById('start-button');
startBtn.addEventListener('click', beginSearch)
Also see: Tab Triggers