Avatar of Stephen Kairys
Stephen Kairys
Flag for United States of America asked on

What language is this code snippet?

Hi, I'm documenting a change in a web page (not written by my company)and encountered the following snippet. What language is it? JavaScript? Thanks.

(function() { function forEach(responses, cb) { Object.keys(responses).forEach(function(adUnitCode) { var response = responses[adUnitCode]; response.bids.forEach(function(bid) { cb(adUnitCode, bid); }); }); } var winners = pbjs.getAllWinningBids(); var output = []; forEach(pbjs.getBidResponses(), function(code, bid) { output.push({ bid: bid, adunit: code, adId: bid.adId, bidder: bid.bidder, time: bid.timeToRespond, cpm: bid.cpm, msg: bid.statusMessage, rendered: !!winners.find(function(winner) { return winner.adId==bid.adId; }) }); }); forEach(pbjs.getNoBids && pbjs.getNoBids() || {}, function(code, bid) { output.push({ msg: "no bid", adunit: code, adId: bid.bidId, bidder: bid.bidder }); }); if (output.length) { if (console.table) { console.table(output); } else { for (var j = 0; j < output.length; j++) { console.log(output[j]); } } } else { console.warn('NO prebid responses'); } })(); 

Open in new window

ProgrammingJavaScriptProgramming Languages-Other

Avatar of undefined
Last Comment
Zakaria Acharki

8/22/2022 - Mon
David Favor

Looks like Javascript.
Sam Jacobs

Yes, that is JavaScript.
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Stephen Kairys

ASKER
Thanks, everyone!
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Stephen Kairys

ASKER
Follow-up: Is the below also Javascript:

<script src = "https://cdn.jsdelivr.net/npm/prebid-universal-creative@latest/dist/creative.js"></script>
<script>
  var ucTagData = {};
  ucTagData.adServerDomain = "";
  ucTagData.pubUrl = "%%PATTERN:url%%";
  ucTagData.targetingMap = %%PATTERN:TARGETINGMAP%%;

  try {
    ucTag.renderAd(document, ucTagData);
  } catch (e) {
    console.log(e);
  }
</script>

Open in new window

Zakaria Acharki

Yes, javascript too, I would suggest to you two websites helps you to identify the programming language of the given code :

This website gives you logical results :

https://creativetechguy.com/utilityprograms/codedetector

This algorithm requires a quick sing up but gives the best result :

https://algorithmia.com/algorithms/PetiteProgrammer/ProgrammingLanguageIdentification